ZF2: Get module name (or route) in the application layout for menu highlight

前端 未结 3 1109
庸人自扰
庸人自扰 2021-01-13 01:19

How can I get in ZF2 the current (selected) module name in the application layout? Purpose: My application layout include the main menu of the zf2 app, and every time a modu

3条回答
  •  长情又很酷
    2021-01-13 01:48

    I prefer easier way without dealing with Module.php

    Place this code into layout.phtml

    $routeName = $this->getHelperPluginManager()->getServiceLocator()->get('Application')
                   ->getMvcEvent()->getRouteMatch()->getMatchedRouteName();
    if($routeName === "users") ...
    

提交回复
热议问题