2009-12-17 51 views
0

我遇到了問題,當在Zend_Config_Xml的實例上調用Zend_Navigation時引發異常。Zend:使用Zend_Config_Xml和Zend_Navigation創建麪包屑導航

下面是在其中在(bootstrap.php中)失敗的方法,包括:

protected function _initNavigation() { 
$this->bootstrap('layout'); 
$layout = $this->getResource('layout'); 
$view = $layout->getView(); 
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml'); 
$navigation = new Zend_Navigation($config); // exception is thrown here 
$view->navigation($navigation); 
} 

被解析該XML文件是完全例37.11的@http://framework.zend.com/manual/en/zend.navigation.containers.html

副本被拋出的錯誤:

  • 致命錯誤:在/usr/share/php/Zend/Navigation/Page.php:223 St中帶有消息'無效參數:無法確定類實例化'的未捕獲異常'Zend_Navigation_Exception' ack trace:#0 /usr/share/php/Zend/Navigation/Container.php(117):Zend_Navigation_Page :: factory(Array)#1 /usr/share/php/Zend/Navigation/Container.php(164): Zend_Navigation_Container-> addPage(Array)#2 /usr/share/php/Zend/Navigation.php(46):Zend_Navigation_Container-> addPages(Object(Zend_Config_Xml))#3 /www/padilla/application/Bootstrap.php(50) :Zend_Navigation - > __ construct(Object(Zend_Config_Xml))#4/usr/share/php/Zend/Application/Bootstrap/BootstrapAbstract.php(615):Zend_Application_Bootstrap_BootstrapAbstract - > _ executeResource('navigation')#6 /usr/share/php/Zend/Application/Bootstrap/BootstrapAbstract.php(579):Zend_Application_Bootstrap_BootstrapAbstract - > _ bootstrap(NULL)# 7 /usr/share/php/Zend/Application.php(347):Zend_Application_B in /usr/share/php/Zend/Navigation/Page.php on line 223

也許我錯過了一些東西,或者xml結構需要修改/定製?

+0

你可以粘貼你的navigation.xml嗎? – 2009-12-17 03:43:54

回答

4

您的實例Zend_Config_Xml與示例不同。您忘記將該部分指定爲第二個參數。

$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav'); 

如果添加, 'nav'位在那裏,assumming你的XML是酷似一箇中的鏈接,它應該工作。

+0

傻我........ – 2009-12-17 04:01:46