I have a route defined in config.php that currently checks the URL pattern to see if it has /landscape or /portrait on the end, then passes the appropriate value to the page before passing it along. I need this to work here as there are several places it is used where the detected orientation is wrong when using HTML/CSS/JS, or those detection methods are unsupported. Every time I try to get help with this, everyone gets hung up on why, and forgets to answer how, so there’s the why.
The following works, but it hard-set to a single page. I need this function to pass the data to the controller but to the current page, no matter it’s name. I attempted to do this with return page($page)->render($data);
but it returned an error that $page was undefined. This is confusing because I see other examples where $page is used to return the current page in config.php.
here is the full router code:
'routes' => [
[
'pattern' => 'slideshows/(:any)/landscape',
'action' => function ($value) {
$data = [
'orientation' => $value,
];
return page('slideshows/selfcheck')->render($data);
}
],
[
'pattern' => 'slideshows/(:any)/portrait',
'action' => function ($value) {
$data = [
'orientation' => $value,
];
return page('slideshows/selfcheck')->render($data);
}
]
]
All I need is to check the URL for landscape or portrait, then set the appropriate value, so if there’s a better way to do that in config.php, i’m happy to do that.