How can I achieve something like this ?
This doesn’t work…
Kirby::plugin('plugin/kirby-functions', [
'routes' => [
[
'pattern' => 'artists/(:any)/exhibitions-and-news',
'action' => function ($uid) {
$page = page('artists/'.$uid);
return Tpl::load(kirby()->roots()->templates() . DS . 'exhibitions-and-news.php', array('page' => $page));
}
]
]
]);
Thank you for your help.
texnixe
September 9, 2019, 9:09am
3
You can render the page:
Kirby::plugin('plugin/kirby-functions', [
'routes' => [
[
'pattern' => 'artists/(:any)/exhibitions-and-news',
'action' => function ($uid) {
if ($page = page('artists/'.$uid)) {
return $page->render();
}
$this->next();
}
]
]
]);
If necessary, the render method allows you to pass additional data to the page:
And sorry, somehow overlooked your question.
Thank you @texnixe .
I would need to load a specific template that has no pages in content.
The only way to do it is to use virtual pages then ?
texnixe
September 9, 2019, 9:26am
5
Loading the template like you did should work as well, the downside of this approach is that you have to pass all needed variables along, including to each snippet. So you would have to call the header snippet in your template like this:
<?php snippet('header', ['site' => $site, 'page' => $page]) ?>
etc.
1 Like