Zend Framework-导航设置当前页面标题并打开标记标题导航.xml
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zend Framework-导航设置当前页面标题并打开标记标题导航.xml相关的知识,希望对你有一定的参考价值。
If you have Zend_Navigation in your application, you will use navigation.xml. This code set the page title ($this->view->headTitle()) with the current page title in navigation.xml.$navigation->current() doesn't work in my opinion.
/configs/navigation.xml <nav> <home> <title>Home</title> <label>Home</label> <module>admin</module> <controller>index</controller> <action>index</action> </home> <communities> <title>Communities</title> <label>Communities</label> <module>admin</module> <controller>communities</controller> <action>index</action> </communities> </nav> class App_Controller_Plugin_Navigation extends Zend_Controller_Plugin_Abstract { public function preDispatch(Zend_Controller_Request_Abstract $request) { //$view = Zend_Registry::get('view'); $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'); $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav'); $navigation = new Zend_Navigation($config); $view->navigation($navigation); //search current page's title on navigation.xml by Controller Name $pages = $view->navigation()->findAllByController($request->getParam('controller')); } else { $navPage = $this->_getCurrentPageFromController($pages, $request->getParam('action')); } $translate = Zend_Registry::get('Zend_Translate'); $view->headTitle()->prepend($translate->_($navPage->getTitle())); } foreach ($pages as $page) { if ($page->action == $action) { return $page; } } throw new Exception("Can't find page in navigation..."); } } /configs/application.ini resources.frontController.plugins.Navigation = "App_Controller_Plugin_Navigation"
以上是关于Zend Framework-导航设置当前页面标题并打开标记标题导航.xml的主要内容,如果未能解决你的问题,请参考以下文章
PHP Zend Framework:设置Zend Navigation
zend framework 重定向方法(render, forward, redirect)总结