EzDevInfo.com

kirby

a stripped down and easy to use toolkit for PHP Kirby is a file-based cms | Kirby kirby is a file-based content management system – easy to setup, easy to use, flexible as hell.

Setting up RSA key on website

Currently I am developing a site with very secure information and want to use jCryption - http://www.jcryption.org/ - to encrypt all of my forms. I am a beginner to RSA keys/form encryption and would like to know the correct and most secure way to set this up. I am using kirby CMS as well. Do I add my RSA keys to a .ssh folder within my site’s directory or add one to my database? Any direction would be greatly appreciated


Source: (StackOverflow)

Kirby CMS, how to get the first image from an Object with PHP?

im currently trying out some stuff with Kirby CMS.

Right now I'm trying to build a simple blog with some pictures and what i want to achieve, is that the first, and only the first picture in the blog post, ist shown in the post overview together with a short excerpt from the text.

So Im using the $page->images() function from kirby, which gives me the urls from all the pictures in the post. But I want only the first picture! Because i cant find any documented options to do that with the kirby functions i tried to do it in php.

what i figured out:

-kirby returns an object.
-i couldnt find any php-method to slice something from an object so i tried to convert it to an array:

$pictureArray = (array) $article->images();

-then i tried to use array_slice, which returned strange results so i took a closer look at my array. print_r($pictureArray); returns this:

Array ( [pagination] => [_] => Array ( [test.jpg] => image Object ( [meta] => Array ( ) [_] => Array ( [name] => test [filename] => test.jpg [extension] => jpg [root] => /home/exampledbq/www.example.com/kirby/content/01-articles/02-zweiter-Eintrag/test.jpg [uri] => content/01-articles/02-zweiter-Eintrag/test.jpg [parent] => files Object ( [pagination] => [_] => Array ( [article.txt] => variables Object ( [meta] => Array ( ) [_] => Array ( [name] => article [filename] => article.txt [extension] => txt [root] => /home/exampledbq/www.example.com/kirby/content/01-articles/02-zweiter-Eintrag/article.txt [uri] => content/01-articles/02-zweiter-Eintrag/article.txt [parent] => files Object *RECURSION* [modified] => 1354712997 [type] => content [variables] => Array ( [title] => Der zweite Eintrag [description] => Zusammenfassung. [published] => 18.12.2012 [tags] => Image, Article [text] => Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. (image: test.jpg) (image: test2.jpg) ) [filecontent] => Title: Der zweite Eintrag ---- Description: Zusammenfassung. ---- Published: 18.12.2012 ---- Tags: Image, Article ---- Text: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. (image: test.jpg) (image: test2.jpg) [languageCode] => en [template] => article ) ) [test.jpg] => image Object *RECURSION* [test2.jpg] => image Object ( [meta] => Array ( ) [_] => Array ( [name] => test2 [filename] => test2.jpg [extension] => jpg [root] => /home/exampledbq/www.example.com/kirby/content/01-articles/02-zweiter-Eintrag/test2.jpg [uri] => content/01-articles/02-zweiter-Eintrag/test2.jpg [parent] => files Object *RECURSION* [modified] => 1354713013 [type] => image [thumb] => image Object *RECURSION* [title] => test2 ) ) ) ) [modified] => 1354712200 [type] => image [thumb] => image Object *RECURSION* [title] => test ) ) [test2.jpg] => image Object ( [meta] => Array ( ) [_] => Array ( [name] => test2 [filename] => test2.jpg [extension] => jpg [root] => /home/exampledbq/www.example.com/kirby/content/01-articles/02-zweiter-Eintrag/test2.jpg [uri] => content/01-articles/02-zweiter-Eintrag/test2.jpg [parent] => files Object ( [pagination] => [_] => Array ( [article.txt] => variables Object ( [meta] => Array ( ) [_] => Array ( [name] => article [filename] => article.txt [extension] => txt [root] => /home/exampledbq/www.example.com/kirby/content/01-articles/02-zweiter-Eintrag/article.txt [uri] => content/01-articles/02-zweiter-Eintrag/article.txt [parent] => files Object *RECURSION* [modified] => 1354712997 [type] => content [variables] => Array ( [title] => Der zweite Eintrag [description] => Zusammenfassung. [published] => 18.12.2012 [tags] => Image, Article [text] => Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. (image: test.jpg) (image: test2.jpg) ) [filecontent] => Title: Der zweite Eintrag ---- Description: Zusammenfassung. ---- Published: 18.12.2012 ---- Tags: Image, Article ---- Text: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. (image: test.jpg) (image: test2.jpg) [languageCode] => en [template] => article ) ) [test.jpg] => image Object ( [meta] => Array ( ) [_] => Array ( [name] => test [filename] => test.jpg [extension] => jpg [root] => /home/exampledbq/www.example.com/kirby/content/01-articles/02-zweiter-Eintrag/test.jpg [uri] => content/01-articles/02-zweiter-Eintrag/test.jpg [parent] => files Object *RECURSION* [modified] => 1354712200 [type] => image [thumb] => image Object *RECURSION* [title] => test ) ) [test2.jpg] => image Object *RECURSION* ) ) [modified] => 1354713013 [type] => image [thumb] => image Object *RECURSION* [title] => test2 ) ) ) )

Anyone know what this is? i mean the image url is in there, but where the hell does all this stuff come from? when i try to echo the $page->images() function it returns only the image urls and not the whole article.

Can anybody help? maybe it is even possible to achieve this with kirby-only functions and not php?


Source: (StackOverflow)

Advertisements

Querying CSV meta data for an image gallery in Kirby

So I downloaded and really enjoyed getting started with Kirby http://www.getkirby.com For those not familiar it is a file based cms.

As standard you can drop a bunch of images in a directory e.g. site/number1 and it will make a gallery for you on a page called site.com/number1. If one of your images is called example.jpg you can make a file called example.txt and put inside information relating to the image such as title, date etc.

I wasn't totally happy with the idea of having a text file for each individual image and having the images scattered around the server in the page folders.

First of all I put a large collection of images in assets and added a variable to the page so I just need to add the image ref e.g. k-45 to a list in the page.txt e.g.

----

Imagelist: a-04, a-08, h-16, i-35

I then added the following snippet:

 <ul class="gallery">
  <?php $imagelist= $page->imagelist();
  if ($imagelist != ''){
$imagelistitem= explode(", ", $imagelist);
foreach ($imagelistitem  as $image): ?>
  <li><img src="<?php echo url('assets/artistswork/450/').$image.'.jpg' ?>" /></li>
      <?php endforeach ;} ?>
    </ul>

This generates an image gallery from the central bank and works great. Sure someone more experienced than me could add some useful validation/error correction but as long as the list is written error free it works fine.

So far this is essentially a Kirby issue, this where my question begins.

Next I wanted to draw meta data for the images from a central csv sheet. E.g title, date, material ect. fields related to the $image variable.

In my csv the first column stock book code will have a figure that is equivalent to the $image variable and I want to use the rest of the information in that row to populate a series of spans that I can format and possibly animate using jquery and parse to fancy box etc.

  1. I need a better piece of code to generate an effective array from my csv. Possibly indexing the results by the stock book number
  2. And a method to query it and parse out the relevant array as a list of variable to use in the injection.

I imagined I could inject the code into the above quoted repeater.

<span class="workTitle">$title</span>
<span class="workDate">$date</span>
<span class="workMaterial">$material</span>
<span class="workDimensions">$dimensions</span>
<span class="workPrice">$price</span>

The first few lines of my csv are:

Stock book code,Date,Work Title,height,width,materials,Ownership
a-04,1962,River Barge,0,0,Oil on Board,Sold
a-08,1962,Thames Bridge Fantasy ,48,36,Oil on Board,Available
h-15,1963,Split Rocks,36,32,Oil on Board,Available
i-35,1964,Moon Dyptych,32,21,Oil on Board,Available

I haven't really got much of a clue how to finish this off. I know it's probably not super difficult but I'm no expert, certainly not when dealing with arrays. The sheet is on the server and using some php I've managed to print the csv-array result but without the header's being the array titles, they were just treated as a line, the first array in the larger array.

So really I'm looking at starting from scratch for the second part of my problem - not expecting a full cut and paste solution by any means but if someone could point me in the right direction it would be great. I haven't used j-query and don't know too much php. However I don't mind doing a lot of reading and spending the time making it work myself but I could do with a point in the right direction.

The in-complete csv-array function I found was as follows. May have to start from stratch with it:

<?PHP
function readCSV($csvFile){
    $file_handle = fopen($csvFile, 'r');
    while (!feof($file_handle) ) {
        $line_of_text[] = fgetcsv($file_handle, 1024);
    }
    fclose($file_handle);
    return $line_of_text;
}


// Set path to CSV file
$csvFile = 'http://localhost/peterliddle/assets/artistswork/imagemeta.csv';

$csv = readCSV($csvFile);
echo '<pre>';
print_r($csv);
echo '</pre>';
?>

This out puts this (and 300 more):

Array
(
    [0] => Array
        (
            [0] => Stock book code
            [1] => Date
            [2] => Work Title
            [3] => height
            [4] => width
            [5] => materials
            [6] => Ownership
        )

    [1] => Array
        (
            [0] => a-04
            [1] => 1962
            [2] => River Barge
            [3] => 0
            [4] => 0
            [5] => Oil on Board
            [6] => Sold
        )

    [2] => Array
        (
            [0] => a-08
            [1] => 1962
            [2] => Thames Bridge Fantasy 
            [3] => 48
            [4] => 36
            [5] => Oil on Board
            [6] => Available
        )

    [3] => Array
        (
            [0] => h-15
            [1] => 1963
            [2] => Split Rocks
            [3] => 36
            [4] => 32
            [5] => Oil on Board
            [6] => Available
        )

Source: (StackOverflow)

"Unexpected token '>'" line 1 after htaccess rewrite (Breaks css & images)

Basically, what I've been aiming at doing is to fix broken links. Old links might point to http://www.example.com/work/funkystuff, and I'm redirecting them to go to http://www.example.com/en/work/funkystuff.

So here are the symptoms of this horrible disease:

  1. Images, Css & Javascript breaks. The console tells me "Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/en/"." for each type.

  2. I get the weird error about "Uncaught SyntaxError: Unexpected token <" on line one of my index.php files, where my doctype is. This leads me to think that it's not even interpreting my .php document as a .php document...

From what I've gathered from my Google sessions, this shouldn't be happening. My links are absolute (echoed out by php), and I have the RewriteCond to only redirect non-existing files & directories (line 4 & 5).

So yeah, this is what my .htaccess looks like.

# enable awesome urls. i.e.: 
# http://example.com/about-us/team
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links will break.
# 
# If your homepage is http://example.com/mysite
# Set the RewriteBase to:
# 
# RewriteBase /mysite
# 
RewriteBase /

# Redirect key areas of the site before localisation.
RewriteRule ^work/(.*)$ /en/work/$1 [NC,R=301,L]
RewriteRule ^news/(.*)$ /en/news/$1 [NC,R=301,L]
RewriteRule ^about/(.*)$ /en/about/$1 [NC,R=301,L]
RewriteRule ^careers/(.*)$ /en/careers/$1 [NC,R=301,L]
RewriteRule ^contact/(.*)$ /en/contact/$1 [NC,R=301,L]
RewriteRule ^update-twitter/(.*)$ /en/update-twitter/$1 [NC,R=301,L]

# redirect everything to index.php
RewriteRule ^(.*) index.php [L]

I hope someone knows what this might be, because I'm confused as hell.

EDIT: I feel that I should add some more information.

We're using a CMS called Kirby and are now starting to move over to a multi-language version of the site. Kirby can do this for us simply, by auto-detecting browser language and redirecting users from domain to domain/language.

The thing is that we're complicating things by using redirects. The language part of the URL isn't a real subdirectory, but rather a name.


Source: (StackOverflow)

kirby .htaceess and GET variables

I'm currently building a gallery in Kirby and have an album page that effectively has two modes: 1) Gallery listing, showing all items. 2) Single Image. I'm passing in a GET variable like so:

/gallery/album-name?p=03.jpg

What I really want is a URL like this:

/gallery/album-name/03.jpg

Kirby already does some url rewriting in its default .htaccess file, like so:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

Which re-writes the urls from this /index.php/gallery/album-name?p=03.jpg removing the index.php part.

Now, I did think I could simply have it rewrite any URL that has a get variable like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/([A-Za-z0-9-]+)?$ index.php?p=$1 [L]

But that didn't seem to work.

My question is this: Can this be done? And if so, will the GET variable still be available to my script?

Many thanks!


My current full re-write rules

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteBase /

#//www. vs //
RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ error [R=301,L]

# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) error [R=301,L]

# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) error [R=301,L]

# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]

# make gallery links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^gallery/(.*)/([A-Za-z0-9-]+\.jpg)?$ index.php?p=$2 [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

This works for everything, but I get a 404 on (for example) this url: /gallery/my-gallery-name/01.jpg


Source: (StackOverflow)

Toggle content with JavaScript and CSS not working in Kirby

I am trying to use the toggle code I found here: http://jsfiddle.net/wGbh5/. It seemed pretty straight forward and doing exactly what I want.

So I had the following code in my style.css file:

.clickme {
background-color: #eee;
border-radius: 4px;
color: #666;
display: block;
margin-bottom: 5px;
padding: 5px 10px;
text-decoration: none;}

.clickme:hover {
    text-decoration: underline;
}

Then I created a toggle.js file containing this code:

// Hide all the elements in the DOM that have a class of "box"
$('.box').hide();
// Make sure all the elements with a class of "clickme" are visible and bound
// with a click event to toggle the "box" state
$('.clickme').each(function() {
    $(this).show(0).on('click', function(e) {
        // This is only needed if your using an anchor to target the "box" elements
        e.preventDefault();

        // Find the next "box" element in the DOM
        $(this).next('.box').slideToggle('fast');
    });
});

and I called both file in my html using, in the header, using the lines

<link rel="stylesheet" rel='nofollow' href="http://localhost:8888/kirby/assets/styles/styles.css" />
<script src="http://localhost:8888/kirby/assets/js/toggle.js"></script>

As you can see in the link, I am working locally using MAMP and trying out the CMS Kirby.

In the HTML file, the code looks like this:

<a rel='nofollow' href="#" class="clickme">Click Me</a>
<div class="box">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
    when an unknown printer took a galley of type and scrambled it to make a type
</div>

The problem is, when I load the html file in my browser, it does not work (I would be here if it worked right?). Both the "clickme" and the "box" content are displayed and nothing appends when I click them.

Can anyone help me with my problem?

Thanks a lot in advance


Source: (StackOverflow)

Building chained function calls dynamically in PHP

I use PHP (with KirbyCMS) and can create this code:

$results = $site->filterBy('a_key', 'a_value')->filterBy('a_key2', 'a_value2');

This is a chain with two filterBy. It works.

However I need to build a function call like this dynamically. Sometimes it can be two chained function calls, sometimes three or more.

How is that done?

Maybe you can play with this code?

chain is just a random number that can be used to create between 1-5 chains.

for( $i = 0; $i < 10; $i ++ ) {
    $chains = rand(1, 5);
}

Examples of desired result

Example one, just one function call

$results = $site->filterBy('a_key', 'a_value');

Example two, many nested function calls

$results = $site->filterBy('a_key', 'a_value')->filterBy('a_key2', 'a_value2')->filterBy('a_key3', 'a_value3')->filterBy('a_key4', 'a_value4')->filterBy('a_key5', 'a_value5')->filterBy('a_key6', 'a_value6');

Source: (StackOverflow)

Absolute URLs with Grunt Usemin / CSSmin while still finding the CSS

Because my site is based on folder structure, I have to add as many ../ as their are levels in the hierarchy or on deeper 'pages' the CSS doesn't load.

Is there a way to get Grunt Usemin / CSSmin to let me use an absolute url?

<!-- build:css(.tmp) ../../assets/styles/main.css -->
<link rel='stylesheet' rel='nofollow' href='../.tmp/styles/main.css'/>
<!-- endbuild -->

When I use /assets/styles/main.css, usemin doesn't find the CSS to minify (but the URL in the HTML is rewritten to the correct absolute url).

Is there a solution in the config of usemin or cssmin?

Below are the relevant parts from my Gruntfile. The full file is on PasteBin

useminPrepare: {
  options: {
    dest: '<%= config.dist.assets %>'
  },
  html: ['.tmp/templates/{,*/}*.html', '.tmp/snippets/{,*/}*.html']
},

usemin: {
  options: {
    assetDirs: '<%= config.dist.assets %>',
    basedir: '',
    dirs: '<%= config.app.root %>'
  },
  html: ['.tmp/templates/{,*/}*.html', '.tmp/snippets/{,*/}*.html'],
  css: '.tmp/styles/{,*/}*.css'
},

Source: (StackOverflow)

Running a secondary PHP app from a subdirectory in Nginx

I have a site built on the Kirby flat file CMS and its running in the root directory just fine, but I'm trying to get an instance of FlightPHP running in a subdirectory (called crm) of the above project. This FlightPHP instance will handle form submissions so I need to be able to map the urls correctly.

With Apache and .htaccess, it's easy:

# make forms/crm links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^crm/(.*) crm/index.php [L]

I just can't seem to get this working with Nginx, here's what I have so far:

server {
  listen 80;
  listen [::]:80;
  root /var/www/mainsite;
  index index.php index.html index.htm;
  server_name mydomain.com;
  autoindex on;
  access_log off;

  # Kirby Specific Directories
  rewrite ^/site/(.*) /error permanent;
  rewrite ^/kirby/(.*) /error permanent;    

  add_header X-UA-Compatible "IE=Edge,chrome=1";

  location ~ .php {
      fastcgi_pass  unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_hide_header X-Powered-By;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_script_name;
      fastcgi_buffer_size 128k;
      fastcgi_buffers 256 16k;
      fastcgi_busy_buffers_size 256k;
      fastcgi_temp_file_write_size 256k;        
      include fastcgi_params;            
  }

  location ^~ /crm {
      root /var/www/mainsite/crm;

      if (!-e $request_filename)
      {
          rewrite ^/(.*)$ /index.php/$1 last;
          break;
      }
  } 

  location / {
      try_files $uri $uri/ /index.php?$query_string;
  }   

  location ~* .(?:xml|ogg|mp3|mp4|ogv|svg|svgz|eot|otf|woff|ttf|css|js|jpg|jpeg|gif|png|ico)$ {
    try_files $uri =404;
    expires max;
    access_log off;
    log_not_found off;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  }         
}

I have tried quite a few approaches from similar posts online, but none that work correctly.


Source: (StackOverflow)

Kirby CMS - add an image modified timestamp

I'm learning Kirby CMS.

I have a page displaying a series of images, I'm unsure how to get the date the image was uploaded.

I think it is something to do with the $file variable?:

$file->modified($format=false)
the last modified timestamp

here is my php loop:

<?php if($page->hasImages()): ?> 
    <ul class="gallery">
        <?php foreach($page->images() as $image): ?>
            <div class="gallerySegment">
            <h3 class="guidelineHead"><?php echo $image->title() ?></h3>
            <p><?php echo $image->caption() ?></p>
            <li><img src="<?php echo $image->url() ?>" width="<?php echo $image->width() ?>" height="<?php echo $image->height() ?>" alt="<?php echo $image->title() ?>" /></li>
            </div>
        <?php endforeach ?>
    </ul>
<?php endif ?>

Source: (StackOverflow)

htaccess ignore rewrite to api url

I’ve build the front end of a site using angular and have created the cms through Kirby. Kirby allows you to build a json api from the structure you create with the cms, like so.

What I’m trying to do now is use the api provided by Kirby which is:

address.com/projects/api 

within my angular app. I’m using html5 and htaccess to rewrite my urls so I dont need to use a hash within the url and page refreshes on a subpage get redirected to the appropriate angular view.

address.com/work
address.com/about
address.com/single-project

my htaccess looks like this

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html

Kirby requires its own htaccess to serve pages also, so my question... Is it possible to allow access to my json template at address.com/projects/api and still preserve the angular clean urls?


Source: (StackOverflow)

Foreach: Group same data

I am attempting to group generated data from a foreach statement by date. I am using Kirby CMS but am having troubling accomplishing the following.

Goal (sudo):

date: 03/10/15
Take Over

date: 03/09/15
Video
Flash
Super GIF 2
Super GIF
Image

My Attempt:

date: 03/10/15
Take Over
date: 03/09/15
Video
date: 03/09/15
Flash
date: 03/09/15
Super GIF 2
date: 03/09/15
Super GIF
date: 03/09/15
Image

Code:

  <ul>
    <?php foreach($page->children()->visible()->sortBy('modified', 'desc')  as $projects): ?>
      <li>
        date: <?php echo $projects->modified('m/d/y') ?> <br>
        <a rel='nofollow' href="<?php echo $projects->url() ?>"><?php echo $projects->title()->html() ?></a>
      </li>
    <?php endforeach  ?>  
  </ul>

Second unsuccessful attempt:

  <ul>
      <?php foreach($page->children()->visible()->sortBy('modified', 'desc')  as $projects): ?>
       <li>
          <?php foreach($page->children()->visible()->sortBy('modified', 'desc')  as $project): ?>

            <?php 
              if($projects->modified('m/d/y') == $project->modified('m/d/y')) {
                echo $project->modified('m/d/y') . '<br>' . $project->title();
              }

            ?>

          <?php endforeach  ?>  
       </li>


    <?php endforeach  ?>  
  </ul>

Output:

03/10/15
Take Over
03/09/15
Video 03/09/15
Flash 03/09/15
Super GIF 2 03/09/15
Super GIF 03/09/15
Image
03/09/15
Video 03/09/15
Flash 03/09/15
Super GIF 2 03/09/15
Super GIF 03/09/15
Image
03/09/15
Video 03/09/15
Flash 03/09/15
Super GIF 2 03/09/15
Super GIF 03/09/15
Image
03/09/15
Video 03/09/15
Flash 03/09/15
Super GIF 2 03/09/15
Super GIF 03/09/15
Image
03/09/15
Video 03/09/15
Flash 03/09/15
Super GIF 2 03/09/15
Super GIF 03/09/15
Image

Source: (StackOverflow)

Kirby: MarkdownExtra doesn't produce wanted paragraphes, renders line-breaks instead

I'm currently getting my head around http://getkirby.com and am very pleased to far. I activated Markdown Extra which comes shipped with Kirby so I can use Markdown within div-elements.

This works pretty well until the point where I need to create separate paragraphes of text, like so:

<div class="my-class" markdown="1">
    This is the first paragraph

    This is the second paragraph
</div>

Instead of rendering it like this:

<div class="my-class">
    <p>This is the first paragraph</p>

    <p>This is the second paragraph</p>
</div>

I get this result:

<div class="my-class">
    <p>This is the first paragraph<br />
    This is the second paragraph</p>
</div>

Is this wanted behavior I can control or is there something wrong with the parser?

Thanks for your help up front.


Source: (StackOverflow)

Kirby snippet shows only 10 subpages

I'm working on this (NSFW), I created 12 subpages but only 10 are showing in the list. I'm not using any limit() or pagination() in the snippet nor in the panel config, I can't find where this limit is regulated. My guess is a numbering issue, because if in the panel I drag up the 11th subpage up, anything below will not be displayed. Any clue?

php:

<section id="entries">
 <ul>
  <li>
   <div class="line asger">
    <div class="text">00</div>
    <div class="text bold">Asger Carlsen</div>
   </div>
  </li>

<?php $n = 1; foreach($pages->children()->visible()->sortBy('date', 'asc') as $entries): ?>

 <li>
  <div class="line">
   <div class="text">0<?php echo $n++; ?></div>
   <div class="table"><div class="text bold"><?php echo kirbytext($entries->title()) ?></div></div>
   <div class="text"><?php echo kirbytext($entries->kind()) ?></div>
  </div>

  <div class="description hidden">
   <?php echo kirbytext($entries->description()) ?>
  </div>

  <div class="left-half">
   <img class="images hidden" src="<?php echo $entries->images()->first()->url() ?>" alt="<?php echo html($entries->title()) ?>" />
  </div>
 </li>
<?php endforeach ?>
</ul>
</section>

Folder structure: https://www.dropbox.com/s/8gigspwup0kwqei/Screenshot%202014-09-03%2015.39.51.png?dl=0


Source: (StackOverflow)

Kirby CMS - help understanding chaining and objects

We're working with the php-based CMS Kirby but are having trouble understanding where we can (and can't) use chaining (we're pretty green when it comes to php).

We have a product section like this:

|_Shop
  |_Sheets
    |_Sheet one
    |_Sheet two
  |_Bed spreads
    |_Bed spread one
    |_Bed spread two

And are trying to deliver a list of all the product child pages under each category.

How do we do this?

We keep seeing a lot of "Call to a member function on a non-object" errors which we're assuming has to do with the way we're chaining things - e.g. we've tried many ways of doing this but are currently trying:

$productPages = $pages->findByDirname('sheets, duvet-covers, bed-spreads, pillowcases, table-linen');

But are unsure how to find the children of these pages as adding ->visible()->children() either to the end of $pages above or into the foreach loop like this results in errors:

<?php foreach($productPages->visible()->children() as $pageList) : ?>

Also, we can see that the $page variable has the ->visible()->children() variables so assume we need to hand our $productPages variable over to the $page variable so we can use visible()->children() but are unsure how to construct things sorry.

Any pointers in the right direction would be much appreciated.

Cheers


Source: (StackOverflow)