This is a ZF2 question.
I'm trying to change my template, depending on a variable setted on my controller (since is there that im going to decide which template use). In my module onBooststrap i have:
$this->eventManager->attach('dispatch', function($e)
{
if (0 === strpos($e->getRouteMatch()->getParam('controller'), __NAMESPACE__, 0))
{
$e->getViewModel()->setTemplate('layout');
}
}, -100);
and in my controller:
class IndexController extends AbstractActionController
{
public function indexAction ()
{
$view = new \Zend\View\Model\ViewModel();
$view->setVariable("layout", "layout");
return $view;
}
}
but, how do i get access to that view variable "layout", so i can change it in the dispatch event on setTemplate?