获取请求参数时不显示子菜单
我有一个 navigation.xml
文件,其中有一个简单的菜单,在
标记内有一个子菜单。 子菜单运行良好,除非我在 url 中添加了 $_GET
参数。
像这样: admin/manage/pages/id/1
<-- 使用此 url,子菜单不会显示
链接解释: {module}/{controller}/{action}/{key}/{value}
我想我没有更多信息,因为我的设置只是基本的,而且行为很奇怪。
希望您知道哪里出了问题。
顺便说一句:我使用默认路由。
编辑:我使用以下代码来显示子菜单的 $this->navigation()->menu()->setMaxDepth(0);
(这两个代码建议均来自 ArtWorkAD< /strong> 不起作用)
这是我的 navigation.xml:` 网站 /
<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>
`
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>
`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有些人说这是一个错误,但我认为有一个简单的解决方法。
看看这个问题:Zend_View_Helper_Navigation_Menu::renderSubMenu() 默认应该使用 minDepth=1< /a>
因此,请尝试像这样使用 minDepth
如果这不起作用,请尝试将子菜单项添加到子菜单中以查看会发生什么,它现在应该会呈现您的子菜单。
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
If this does not work try to add a submenu item to your submenu to see what happens, it should render you submenu now.
ArtWorkAD 你是对的!我发现我做错了什么。
现在的工作代码是:
navigation()->menu()->setUlClass('navigation-submenu')->renderMenu(null,
array('minDepth' => 2, 'maxDepth' => 2)); ?>
所以你的答案是正确的!
在我的 XML 文件中,我需要有额外的子子页面。非常感谢您的解决方法!
我将您的帖子标记为答案。
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.