Route to load a page in a specific template (w/o subfolder)

i am trying to use a router to create more or less static subpages with certain templates without always having to create subfolders each time…

let’s say my structure is like that:

product-1
product-1/detail
product-1/overview
product-1/print

while i setup the page itself (product-1) it’ll have all informations needed to be able to create each of those subpages, thus i’d not need to manually create a folder each time.

	array(
		'pattern' => '(:any)/detail',
		'action' => function($uid) {
                      // go to $uid/config and use this config-template (passing all $page variables are necessary obviously)

			}
	)

Try tpl::load(). Problem is, you have to pass all variables ($site, $page) to the template.

i was on my way getting it solved… that’s right it works now.

	array(
		'pattern' => '(:any)/config',
		'action' => function($uid) {
			$data = array(
				'kirby' => kirby(),
				'site'  => site(),
				'pages' => site()->children(),
                                'page' => page($uid),
				);
			 echo tpl::load(kirby()->roots()->templates() . DS . 'detail.php', $data, true);
			}
	)
1 Like
<?php snippet('header', array('site' => $site, 'page' => $page)) ?>

will also have to pass around other variables in comparision to using with folders :confused: