Hi,
I’m trying to create a custom route that shows an alternative template to a page. The original page is at the url
/events/event-name
and at the custom route
/events/event-name/media
I want to show some fields from the page in a different layout. I got it to work, like this:
'routes' => [
[
'pattern' => 'events/(:any)/media',
'action' => function ($name) {
return new Page([
'slug' => $name,
'template' => 'event-media',
'content' => page('events/' . $name)->toArray()['content']
]);
}
]
]
but I was wondering if this actually the best way to do it.
Thanks in advance,
Till