Zend Navigation - 各种导航块
我有一个 navigation.xml
文件:
<?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>
此配置文件定义了两个导航框,一个是programm_nav,另一个是acc_nav。
在我的引导程序中,我执行以下操作:
$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' ) );
在我的视图中,我显示导航:
$navSec = $this->navigation ()->findOneByLabel ( 'acc_nav' );
echo $this->navigation ()->menu ()->renderMenu ( $navSec );
但无论我如何定义 $navSec
我总是显示 programm_nav
而不会显示另一个框。 acc_nav
永远不会显示。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
findOneByLabel('acc_nav');
将搜索标签中的文本,因为没有 acc_nav 值。它不会找到它。
findOneByLabel('acc_nav');
will search for text in<label>
-tags as there is nog acc_nav value. It won't find it.我已经复制了这个,这就是发生的事情......
我得到两个链接,一个用于
test1
,一个用于test2
。我必须删除您的
ACL
代码,因为我没有它,所以请尝试删除它。如果它有效,那么您就知道您的ACL
设置不正确。我只是将导航包含到注册表中,然后将其返回到脚本文件中。这很可能不是最好的方法,但考虑到 ZF 文档,这是我唯一的解决方案。现在可能会更好地记录它。
在我的 Bootstrap 中
,我的视图文件如下所示
I have replicated this and this is what happened ....
I get two links, one for
test1
and one fortest2
.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 yourACL
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
And my view file looks like this