Well, after some reading, I don’t have a clue where to start. Any points? Should I include a URL input field in the blueprint and then somehow make that work with a router?
Thanks, @texnixe, great help as always. However, my site structure was just an example, and in fact I will like to have any inner pages render as a root URL page. Consider the following structure:
Industries (URL: /industries)
Life Sciences (URL: /industries/life-sciences-translation-service)
c::set('routes', array(
array(
'pattern' => '(:any)',
'action' => function($uid) {
// check if the page exists
$page = page($uid);
// then check here each level, so first industries and then each other level and the same for all other pages that have subpages
if(!$page) $page = page('industries/' . $uid);
if(!$page) $page = page('industries/life-sciences/' . $uid);
// etc.
if(!$page) $page = site()->errorPage();
return site()->visit($page);
}
),
array(
'pattern' => '(:all)/(:any)',
'action' => function($uri,$uid) {
go($uid);
}
)
));
Keep in mind that you have to make sure that none of your pages on any level use the same URL, otherwise some of your pages won’t be accessible anymore (for example, if any of the subpages in one of the trees had the same UID as a subpage of one of the other page trees).
// we try to get a page by passing the uid to the page helper, this is true if the page exists and false if it doesn't
$page = page($uid);
// so if $page is not a page (! = not), then we check if we get a page one level down, two levels down etc.
if(!$page) $page = page('industries/' . $uid);
if(!$page) $page = page('industries/life-sciences/' . $uid);
// etc.
// when after all that we still don't have a page, we redirect to the error page
if(!$page) $page = site()->errorPage();