开发者

giving errors in bootstrap when try to use breadcrumbs in zend framework

开发者 https://www.devze.com 2023-03-02 11:35 出处:网络
hi i want to use a breadcrumb for my zend framework application i craeted navigation.xml in configs folder where application.ini is .

hi i want to use a breadcrumb for my zend framework application

i craeted navigation.xml in configs folder where application.ini is .

and in the bootstarp i added following code

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);
}

and in the layout i added folllowing code

    <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>

it is not working , errors are given

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 

this is my xml file

<?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>
                            <controll开发者_运维百科er>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>   

i am not sure what the error is . please help me ................


The error is due to your config file.

You're not providing enough parameters for the navigation container to determine the correct page type, Zend_Navigation_Page_Mvc or Zend_Navigation_Page_Uri.

Also, you know there's a navigation resource plugin, right?

UPDATE

Get rid of the <nav> wrapper element. It's trying to interpret that as a page.

That or do follow the example and specify the config section correctly

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

精彩评论

暂无评论...
验证码 换一张
取 消