I simply mean that you should check as following (pseudocode): $viewModel = $controller->getEvent()->getViewModel(); if (!$viewModel->getVariable('controller')) { $viewModel->setVariable('controller', $route->getParam('controller')); }
Marco Pivetta http://twitter.com/Ocramius http://marco-pivetta.com On 18 May 2012 17:50, cmple <roman.vidya...@gmail.com> wrote: > > Marco Pivetta wrote > > > > Careful, I would not just blindly overwrite them. Leave the ones that are > > currently set, or make that logic configurable :) > > > > Marco Pivetta > > > > http://twitter.com/Ocramius > > > > http://marco-pivetta.com > > > > > > > > On 18 May 2012 15:37, cmple [via Zend Framework Community] < > > ml-node+s634137n4644518h78@.nabble> wrote: > > > >> I finally solved it.. > >> > >> // Module.php > >> public function init(Manager $moduleManager) { > >> > >> $sharedEvents = $moduleManager->events()->getSharedManager(); > >> $sharedEvents->attach('bootstrap', 'bootstrap', array($this, > >> 'initializeView'), 100); > >> > >> $sharedEvents->attach('Application', 'dispatch', function($e) { > >> $controller = $e->getTarget(); > >> $route = $controller->getEvent()->getRouteMatch(); > >> > >> $controller->getEvent()->getViewModel()->setVariables(array( > >> 'controller' => $route->getParam('controller'), > >> 'action' => $route->getParam('action'), > >> )); > >> },100); > >> } > >> > >> // layout.phtml > >> <?php echo "{$controller}/{$action}; "; ?> > >> > >> ------------------------------ > >> If you reply to this email, your message will be added to the > discussion > >> below: > >> > >> > http://zend-framework-community.634137.n4.nabble.com/ZF2-Access-controller-name-action-from-layout-tp4624104p4644518.html > >> To unsubscribe from Zend Framework Community, click > >> here< > http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=634137&code=b2NyYW1pdXNAZ21haWwuY29tfDYzNDEzN3wxNzE0OTI1MTk4> > ; > >> . > >> NAML< > http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > ; > >> > > > Not sure what you mean, can you give me a code example? > > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/ZF2-Access-controller-name-action-from-layout-tp4624104p4644681.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- > List: fw-general@lists.zend.com > Info: http://framework.zend.com/archives > Unsubscribe: fw-general-unsubscr...@lists.zend.com > > >