Kirby 1.0.3

Another week, another minor release. There has still been a tiny bug in the sortBy() method for pages and files. It all worked well unless you were trying to sort dates. I double and tripple checked and it's working fine now. Sorry for that.

Download the latest version here.

What's new?

I took the chance to include some cool new feature requests in this release:

Extendable Kirbytext

@nerdismus asked if it would be possible to extend the kirbytext class so you could add your own text formatting tags. That's actually a very good suggestion and so I made the kirbytext class extendable.

I will write a more detailed article about how to extend kirbytext soon, but you can find a quick example over at Github: https://gist.github.com/1662410

filterBy()

I was asked by a bunch of users if it would be possible to filter a list of pages by the value of a certain field. Right now you could use i.e.…

$page->children->findBy('title', 'Contact');

…but it would only return a single page. You can use the new filterBy method now, which will return a set of pages, which match the given value.

// filter the main pages
$pages->filterBy('category', 'design');

// filter any subpages
$pages->find('projects')->children()->filterBy('category', 'design');

// filter subpages of the current page
$page->children()->filterBy('draft', 'yes');

But the best thing about this new method is, that you can also use it to filter by a keyword, which is contained in a comma separated field value.

Especially if you want to add multiple tags or keywords for each article in a blog or projects in a portfolio, you can now do something like this:

Title: Some title
----
Tags: design, fun, photography
----
Text: Some text
----

This is how you get a list of all pages with the tag design:

$result = $page->children()->filterBy('tags', 'design', ',');

foreach($result as $row) {
  // do something fancy with that page here
}

The third argument for filterBy determines the character, which Kirby will use to split the field value to build a list. So you could also write your list of values like this:

Keywords: app | fun | nice | whatever

… and fetch the results like this …


$result = $page->children()->filterBy('keywords', 'fun', '|');

I've used this new feature to build the tag filter for this blog. I will write a new article about this together with a tutorial how to build a tagcloud next.

param()

There's an article about all the things you can do with the URI object of Kirby and one thing is to access those params (that's how I call them) in URLs:

http://yourdomain.com/somepage/param1:value1/param2:value2

Until now you could get the value of those params like this:

echo $site->uri->params('param1');
// will echo: value1

echo $site->uri->params('param2');
// will echo: value2

In the new version you get a shortcut for this, so all you need to write is:

echo param('param1');
// will echo: value1

echo param('param2');
// will echo: value2

How to update?

Download the latest version here.
Replace your old kirby system folder with the new kirby system folder from the download.

If you are already running your site in production, you should make a backup of your old kirby folder so you can roll back anytime if something goes wrong.

Our partners

CDN by KeyCDN Search by Algolia

Top