尝试在zend框架中使用breadcrumb时在bootstrap中出错

时间:2011-05-04 04:33:47

标签: zend-framework

嗨我想在我的zend框架应用程序中使用breadcrumb

我在configs文件夹中创建了navigation.xml,其中application.ini是。

并在bootstarp中添加了以下代码

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);
    $view->navigation($navigation);
}

在布局中我添加了以下代码

    <div id="menu">
        <?php echo $this->navigation()->menu(); ?>
    </div>
    <div id="breadcrumbs">
        You are in: <?php echo $this->navigation()->breadcrumbs()->setLinkLast(false)->setMinDepth(0)->render(); ?>
    </div>

它不起作用,给出了错误

Fatal error: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation/Page.php:223 
Stack trace: 
#0 /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation/Container.php(117): Zend_Navigation_Page::factory(Array) 
#1 /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation/Container.php(164): Zend_Navigation_Container->addPage(Array) 
#2 /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation.php(46): Zend_Navigation_Container->addPages(Object(Zend_Config_Xml)) 
#3 /home/kanishka/workspace/jetwing_ibe/application/Bootstrap.php(94): Zend_Navigation->__construct(Object(Zend_Config_Xml)) 
#4 /home/kanishka/workspace/jetwing_ibe/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap->_initNavigation() 
#5 /home/kanishka/workspace/jetwing_ibe/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('navigati in /home/kanishka/workspace/jetwing_ibe/library/Zend/Navigation/Page.php on line 223 

这是我的xml文件

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <nav>
        <dashboard>
            <label>dashboard</label>
            <controller>dashboard</controller>
            <action>index</action>
            <resource>dashboard</resource>  
            <pages>
                <rates>
                    <label>Rates</label>
                    <controller>rates</controller>
                    <action>index</action>
                    <pages>
                        <index>
                            <label>index</label>
                            <controller>rates</controller>
                            <action>index</action>
                            <class>dontdisplay</class>
                        </index>                
                    </pages>
                </rates>
                <occupancydenomination>
                    <label>Occupancydenominations</label>
                    <controller>occupancydenomination</controller>
                    <action>index</action>
                    <pages>
                        <index>
                            <label>Occupancydenomination</label>
                            <controller>occupancydenomination</controller>
                            <action>index</action>
                            <class>dontdisplay</class>
                        </index>
                        <add>
                            <label>Add Occupancydenomination</label>
                            <controller>occupancydenomination</controller>
                            <action>add</action>
                            <class>dontdisplay</class>
                        </add>
                    </pages>
                </occupancydenomination>
            </pages>        
        </dashboard>
    </nav>
</config>   

我不确定错误是什么。请帮帮我................

1 个答案:

答案 0 :(得分:2)

错误是由配置文件引起的。

您没有为导航容器提供足够的参数来确定正确的网页类型Zend_Navigation_Page_MvcZend_Navigation_Page_Uri

另外,你知道有一个navigation resource plugin,对吧?

<强>更新

摆脱<nav>包装元素。它试图将其解释为一个页面。

那或遵循example并正确指定配置部分

$config = new Zend_Config_Xml('/path/to/navigation.xml', 'nav');
$container = new Zend_Navigation($config);