【问题标题】:Zend: Creating breadcrumb navigation with Zend_Config_Xml and Zend_NavigationZend:使用 Zend_Config_Xml 和 Zend_Navigation 创建面包屑导航
【发布时间】:2010-10-15 16:41:55
【问题描述】:

我遇到了一个问题,当在 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 中未捕获异常“Zend_Navigation_Exception”,并带有消息“无效参数:无法确定要实例化的类”:223 堆栈跟踪:#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 在 /usr/share/php/Zend/Navigation/Page.php 的第 223 行

也许我遗漏了什么,或者需要更改/自定义 xml 结构?

【问题讨论】:

  • 你能粘贴你的navigation.xml吗?

标签: zend-framework zend-navigation


【解决方案1】:

您的 Zend_Config_Xml 实例化与示例中的不同。您忘记将部分指定为第二个参数。

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

如果您在那里添加, 'nav' 位,假设您的 xml 与链接中的完全相同,它应该可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多