Hi there, I’m effectively looking for a Kirby 3 solution to this old question — ‘Set homepage as most recent content post’.
Which was using c::set('home', page('home')->children()->last());
in the config. It seems this doesn’t work with Kirby 3.
In this case, I’d like to set the homepage as the first page in a ‘work’ folder. So no articles or dates, just whatever the first page is in the work folder.
I know I can solve this by repeating similar code as my work page into my home.php, but would prefer not to load 2 pages if possible!
Thanks again any help is greatly appreciated!!
There is a new home
option for this on Kirby 3. You can set from config.php
like that:
// site/config/config.php
return [
'home' => 'work'
];
To set a page dynamically, you can set the home option within the ready
option:
'ready' => function() {
return [
'home' => page('work')->children()->listed()->sortBy('date', 'desc')->last(),
];
},
Thanks @texnixe! Really appreciate your help with this one. Ready
is a very useful function.
For the record, I only needed the first work item listed so my code looks like this:
// site/config/config.php
return [
'ready' => function ($kirby) {
return [
'home' => page('work')->children()->listed()->first(),
];
}
];