views:

75

answers:

2

Hi,

I have a navigation.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <nav>
        <programm_nav>
            <label></label>
            <uri>#</uri>
            <pages>
                <all>
                    <label>test1</label>
                    <resource>default:programme</resource>
                    <module>default</module>
                    <controller>programme</controller>
                    <action>list</action>
                    <privilege>index</privilege>
                </all>                      
            </pages>
        </programm_nav>
        <acc_nav>
        <label></label>
            <uri>#</uri>
            <pages>
                <ueb>
                    <label>test2</label>
                    <resource>default:account</resource>
                    <module>default</module>
                    <controller>account</controller>
                    <action>index</action>
                    <privilege>index</privilege>
                </ueb>                      
            </pages>
        </acc_nav>
    </nav>
</config>

This config file defines two navigation boxes, one programm_nav and the other acc_nav.

In my bootstrap I do the following:

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

$navContainer = new Zend_Navigation ( $navContainerConfig );

$view->navigation ( $navContainer )->setAcl ( $this->_acl )
->setRole ( Zend_Registry::get ( 'role' ) );

In my view I display the navigation:

$navSec = $this->navigation ()->findOneByLabel ( 'acc_nav' );
echo $this->navigation ()->menu ()->renderMenu ( $navSec );

But no matter how I define $navSec I always displays programm_nav and never another box. acc_nav is never displayed.

Any idea?

A: 

I have replicated this and this is what happened ....

I get two links, one for test1 and one for test2.

I have to remove the code for your ACL because I do not have it, so try removing this. If it then works you then know that the setup of your ACL is incorrect.

I just set the nav contained to the registry then got it back in the script file. This may well not be the best way, but given the ZF docs on this, it was my only solution. It may well be documented better now.

In my Bootstrap I have

function _initNav()
{
    $navContainerConfig = new Zend_Config_Xml ( APPLICATION_PATH . '/configs/navigation.xml', 'nav');     

    $navContainer = new Zend_Navigation ( $navContainerConfig );

    Zend_Registry::set("navigation", $navContainer);        
}

And my view file looks like this

<?php

    $navSec = $this->navigation(Zend_Registry::get("navigation"))
        ->findOneByLabel( 'acc_nav' );

    echo $this->navigation()->menu()->renderMenu( $navSec );

?>
jakenoble
+1  A: 

findOneByLabel('acc_nav'); will search for text in <label>-tags as there is nog acc_nav value. It won't find it.

Skelton
thanks, that helped:)
ArtWorkAD