Set layout variables for use by the (404) error pages in ZF2

前端 未结 2 1452
面向向阳花
面向向阳花 2021-01-22 15:22

At present I set a couple of variables to be used by the app\'s overall layout.phtml, using the onDispatch method of a BaseController, which all my other controllers extend:

2条回答
  •  清歌不尽
    2021-01-22 15:39

    (Necro)

    When using onDispatch in a Controller, remember to return the parent with the event and all:

    public function onDispatch(MvcEvent $e)
    {
        // Your code
        return parent::onDispatch($e);
    }
    

    Otherwise, the logic on your Actions in that Controller will be ignored.

提交回复
热议问题