Zend: Creating breadcrumb navigation with Zend_Config_Xml and Zend_Navigation
I'm having an issue, an exception is thrown when Zend_Navigation
is being invoked on an instance of Zend_Config_Xml
.
Here's the method in which it fails in ( Bootstrap.php ):
protected function _initNavigation() {
$this->bootstrap('layout');
$开发者_C百科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 );
}
The XML file being parsed is EXACTLY a copy of example 37.11 @ http://framework.zend.com/manual/en/zend.navigation.containers.html
The error being thrown:
- Fatal error: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in /usr/share/php/Zend/Navigation/Page.php:223 Stack 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(662): Bootstrap->_initNavigation() #5 /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
Perhaps I'm missing something, or the xml structure needs to be altered/customized?
Your instancing Zend_Config_Xml differently than the example says. You forgot to specify the section as a second parameter.
$config = new Zend_Config_Xml( APPLICATION_PATH . '/configs/navigation.xml', 'nav' );
If you add the , 'nav'
bit there, assumming your xml is exactly like the one in the link, it should work.
精彩评论