Search for CMS pages in alternate theme
1
If you'd like to show pages in an alternate theme (other than the active theme), you can do so by adding this to your plugin's registration file's boot/register method:
Event::listen('cms.page.beforeDisplay', function ($controller, $url, $page) {
if (!$page) {
$altTheme = \Cms\Classes\Theme::load('myOtherTheme');
$altController = new \Cms\Classes\Controller($altTheme);
if ($page = $altController->getRouter()->findByUrl($url)) {
return $page;
}
}
});
If a page with the requested URL is not found in the active theme, it will look for it in the alternate theme.
There are no comments yet
Be the first one to comment