Hi,
Anyone that can give me a hand in merging this routes into one that works. This route setup do not work.
c::set('routes', array(
// Articles route
array(
'pattern' => 'articles/(:any)/amp',
'action' => function($article) {
$page = page('articles/' . $article);
site()->visit($page);
tpl::$data = array_merge(tpl::$data, array(
'kirby' => kirby(),
'site' => site(),
'pages' => pages(),
'page' => page()
), $page->templateData());
echo tpl::load(kirby()->roots()->templates() . DS . 'amp.php');
return false;
}
),
// Logout route
array(
'pattern' => 'logout',
'action' => function () {
if ($user = site()->user()) $user->logout();
go('login');
}
),
// Omit lander and link pages
array(
'pattern' => '(:any)',
'action' => function($uid) {
$page = page($uid);
if(!$page) $page = page('articles/' . $uid);
if(!$page) $page = page('lander/' . $uid);
if(!$page) $page = page('link/' . $uid);
if(!$page) $page = site()->errorPage();
return site()->visit($page);
return false;
}
),
array(
'pattern' => 'articles/(:any)',
'action' => function($uid) {
go($uid);
}
),
array(
'pattern' => 'lander/(:any)',
'action' => function($uid) {
go($uid);
}
),
array(
'pattern' => 'link/(:any)',
'action' => function($uid) {
go($uid);
}
)
));
Thank you!