Zend Framework v1.12
尝试在bootstrap中初始化导航,一切都很好,除了将其附加到视图。 这是一段代码:
protected function _initNavigation() {
$this->bootstrap('view');
$view = $this->getResource('view');
include_once 'views/navigation.php';
$nav = new Zend_Navigation($navigation);
$view->navigation($nav);
}
由于最后一行而发生错误。堆栈跟踪:
Uncaught exception 'Zend_Controller_Router_Exception' with message 'Route archive is not defined' in C:\OpenServer\domains\zend.vortexed\library\Zend\Controller\Router\Rewrite.php:318
Stack trace: #0 C:\OpenServer\domains\zend.vortexed\library\Zend\Navigation\Page\Mvc.php(176): Zend_Controller_Router_Rewrite->getRoute('archive') #1
C:\OpenServer\domains\zend.vortexed\library\Zend\View\Helper\Navigation\HelperAbstract.php(686): Zend_Navigation_Page_Mvc->isActive(false) #2
C:\OpenServer\domains\zend.vortexed\library\Zend\View\Helper\Navigation\Menu.php(740): Zend_View_Helper_Navigation_HelperAbstract->findActive(Object(Zend_Navigation), 0, NULL) #3
C:\OpenServer\domains\zend.vortexed\library\Zend\View\Helper\Navigation\Menu.php(940): Zend_View_Helper_Navigation_Menu->_renderMenu(Object(Zend_Navigation), 'navigation', '', ' ', 0, NULL, false, false, NULL, false, 'active', 'menu-parent', false) #4
C:\OpenServer\domains\zend.vortexed\library\Zend\View\Helper\Navigation\Menu.php(1096): Zend_View_Helper_Navigation_Menu->renderMenu(NULL)
...
转储$nav
表明它很好。
我也试过这样的变种:
protected function _initNavigation() {
$this->bootstrap('layout');
$layout= $this->getResource('layout');
$view= $layout->getView();
include_once 'views/navigation.php';
$nav = new Zend_Navigation($navigation);
$view->navigation($nav);
}
......同样的错误
答案 0 :(得分:1)
答案 1 :(得分:0)
这不是视图或布局错误。 例外情况告诉您路由'archive'未定义。 首先创建“存档”路线。