I have started with a little routing and than it have been growing for a while… All routes worked when the website was single language… And the now with multilingual setup, routes brakes down everywhere.
So home is fine with /
but with /br
it gives me the error 404 page. So how do I make sure all my routes works fine with the new languages?
PS: None of the routes work with the language code. Inclusive the default Kirby routes.
I need a little help to get out of this mess of mine. Please, @texnixe
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('legacy/' . $uid);
if(!$page) $page = page('link/' . $uid);
if(!$page) $page = site()->errorPage();
return site()->visit($page);
return false;
}
),
array(
'pattern' => 'lander/(:any)',
'action' => function($uid) {
go($uid);
}
),
array(
'pattern' => 'legacy/(:any)',
'action' => function($uid) {
go($uid);
}
),
array(
'pattern' => 'link/(:any)',
'action' => function($uid) {
go($uid);
}
)
));
if(!function_exists('panel')) return;
panel()->routes(array(
array(
'pattern' => '(logout)', // the trick here is the parens around the route pattern
'method' => 'GET|POST',
'filter' => array('auth'),
'action' => function() {
if($user = panel()->user()) {
$user->logout();
}
go('/');
},
),
));