public function setLayout(Event $e) { $matches = $e->getRouteMatch(); $controller = $matches->getParam('controller'); if (0 !== stripos($controller, __NAMESPACE__, 0)) { return; } $viewModel = $e->getViewModel(); $viewModel->setTemplate('cron/layout'); }
public function onDispatch(Event $e) { $controller = $e->getTarget(); $serviceManager = $controller->getServiceLocator(); $container = $serviceManager->get('default_navigation'); $vm = $e->getViewModel(); // If no active navigation is found, we revert to 1-col layout foreach ($container as $page) { /* @var $page Mvc */ if ($page->isVisible(false) && $page->isActive(true)) { return; } } // The template has not been changed by the controller, so can override it! if (in_array($vm->getTemplate(), ['layout/layout', 'layout/1-col', 'layout/3-col', 'layout/2-col'])) { $controller->layout('layout/1-col'); } }