Rendering a page with different template


for a client project, I’d like to provide multiple (virtual) pages for a single real page with a different template in Kirby’s content folder. I also want the template to access an extra data variable from the route. I’m trying to realise a sign up page (virtual page that only uses content from real page) for an event (real page).

For the real page, I have a custom route in the config file and render it using something like this:

return page($slug)->render([
  'date' => $date->format('Y-m-d')

How do I now render the exact same page with a different route, accessing the same content and page model, just with a different template and controller? Should I use Page::factory() to create a new page and provide just access to the content variable? Or should I set my real page as parent (as the virtual page is basically a child of such)?

Any advice is appreciated.

For a different template/controller you would actually need a page. But why not use the same controller and template but use different snippets depending on a condition/variable?

However, if you just want to access content from the original page, you can access it from the sign-up page without having to create a duplicated of the original page?

E.g with a route pattern that has a reference to the original page, let’s say 'pattern' => 'originalpage-pattern/signup.

I gave it some thought. Basically I want to create a virtual subpage - works fine like this:

                return Page::factory([
                  'template' => 'signup',
                  'slug' => $page->slug() . '/signup',
                  'parent' => $page,
                ])->render(['date' => $date->format('Y-m-d')]);

Thanks for your help!