Hi all,
Iāve been using Kirby for a couple of weeks, and am about to launch my first Kirby site - yay!
In the process, I found out that apart from all the wonderful features already showcased in the official docs, Kirby has many amazing undocumented features, which can prove extremely useful in a variety of situations. From what I could gather, these are not āexperimentalā features, but rather features that have not made it into the manualā¦yet.
Hopefully, listing them here will help get them added to the manual sooner rather than later, so more folks can enjoy the benefits!
There are many experienced and extremely helpful users in this forum, and I ask you to please contribute to this discussion with the features you know. In order to keep things consistent, please try to follow the format below.
ādeletable: falseā blueprint option for Pages
If you do not want to allow the user to delete the sub-pages of a certain page, you can use the deletable: false
option for pages in the blueprint:
title: My Page
pages:
deletable: false
This option can be combined with the max:
option, to allow you to create pages that have an exact number of sub-pages - which the user cannot add to, nor remove from, for instanceā¦:
title: My Page
pages:
max: 6
deletable: false
ā¦would allow āMy Pageā to have exactly 6 sub-pages, and the user would not be allowed to either delete the existing pages, nor add new ones.
āsort by date and timeā blueprint option for Pages
If you pages have a standard ādateā field, and a standard ātimeā field, you can sort the order in which these pages are listed in the panel like this:
title: Blog
pages:
template:
- article
num: date
format: Ymd
sort: date desc time desc
Of course, you can use asc
instead of desc
for either ādateā or ātimeā.
$pages->sortBy() can sort by more than one field
You can sort a collection of pages by two fields like this:
$articles = $pages->sortBy('date', 'desc', 'time', 'asc');
output snippet() into a variable
The snippet()
function has a third, optional parameter - boolean - which you can set to get it to return the parsed text, instead of āechoingā it to the page. This makes it possible to use snippets in a wide variety of situations, not just inside page templates:
$email_body = snippet('email', $formdata, true);