DelphiLynx
DelphiLynx

Reputation: 921

submenu not showing when having get request params

I have an navigation.xml file, where I have a simple menu, with a submenu within the <pages> tag. The submenu is working well, except when I have addition $_GET params which are in the url.

Like this: admin/manage/pages/id/1 <-- With this url the submenu is not showing

Link explained: {module}/{controller}/{action}/{key}/{value}

I think I have no more information, because my setup is just basic, and the behavior strange.

Hopefully you have an idea where this is going wrong.

Bytheway: I use the default routes.


Edit: I use the following code for displaying the submenu's $this->navigation()->menu()->setMaxDepth(0); (both code suggestions from ArtWorkAD did not work)

Here's my navigation.xml:` Website /

    <beheer>
        <label>Beheer</label>
        <module>admin</module>
        <controller>beheer</controller>
        <uri>/admin/beheer</uri>

        <pages>
    <paginabeheer>
        <label>Pagina beheer</label>
        <module>admin</module>
        <controller>paginabeheer</controller>
        <action>index</action>
                **//THE CODE BELOW IS ADDED ON ArtWorkAD's SUGGESTION**
                <pages>
                    <paginabeheer>
                        <label>Pagina beheer</label>
                        <module>admin</module>
                        <controller>paginabeheer</controller>
                        <action>index</action>
                    </paginabeheer>
                </pages>
                **// END ADDED CODE**
            </paginabeheer>
    </pages>

    </beheer>
</nav>

`

Upvotes: 1

Views: 635

Answers (2)

DelphiLynx
DelphiLynx

Reputation: 921

ArtWorkAD you were right! I have found what I did wrong.

Now the working code is: <?= $this->navigation()->menu()->setUlClass('navigation-submenu')->renderMenu(null, array('minDepth' => 2, 'maxDepth' => 2)); ?>

So your answer was correct! In my XML file it is needed that I have the extra sub-subpage. Thank you very much for your workaround!

I mark your post as answer.

Upvotes: 0

DarkLeafyGreen
DarkLeafyGreen

Reputation: 70416

Some people say this is a bug but I think there is a simple workaround.

Have a look at this issue :Zend_View_Helper_Navigation_Menu::renderSubMenu() should use minDepth=1 per default

So try using minDepth like this

// Navigation 1. Level
echo $this->navigation()->menu()->renderMenu(null, 
          array('minDepth' => 0, 'maxDepth' => 0));

// Navigation 2. Level
echo $this->navigation()->menu()->renderMenu(null, 
          array('minDepth' => 1, 'maxDepth' => 2, 'onlyActiveBranch' => true));

If this does not work try to add a submenu item to your submenu to see what happens, it should render you submenu now.

Upvotes: 1

Related Questions