Zend_Navigation 用于在布局中显示不同的菜单
尝试打印 ZF 上的大约 3 个菜单。目前我连一张都拿不出来。不太清楚发生了什么以及为什么手册上没有提到如何让它工作。
所以这是我的layout.phtml:
<body>
<?php echo $this->layout()->nav; ?>
<?php echo $this->layout()->content; ?>
</body>
不完全确定这是否是我创建导航的方式,但我计划最终更改路线以进行本地化:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<nav>
<register>
<label>Register</label>
<controller>register</controller>
<action>index</action>
</register>
</nav>
</config>
我在我的引导程序中得到了这个:
protected function _initNavigation()
{
// Navigation
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$container = new Zend_Navigation($config);
}
仅显示内容...希望能够有不同的菜单类型,例如... show(topMenu)、show(loggedinSideMenu) 之类的
有什么想法吗?谢谢
trying to print out about 3 menus on ZF. Currently I can't even get one out. Not quite sure what's going on and why theres no mention of how to get it working on the manual.
So this is my layout.phtml:
<body>
<?php echo $this->layout()->nav; ?>
<?php echo $this->layout()->content; ?>
</body>
Not entirely sure if this is how I'm meant to create the navigation but I plan on changing the routes eventually for localization:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<nav>
<register>
<label>Register</label>
<controller>register</controller>
<action>index</action>
</register>
</nav>
</config>
I've got this in my bootstrap:
protected function _initNavigation()
{
// Navigation
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$container = new Zend_Navigation($config);
}
Only the content displays... Wanted to be able to have different menu types like... show(topMenu), show(loggedinSideMenu) sort of thing
Any idea? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有几件事......
首先,要显示导航,请使用适当的帮助程序。在布局文件中...
请参阅 http://framework.zend.com /manual/en/zend.navigation.introduction.html 和 http://framework.zend.com /manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation
其次,
Zend_Application
有一个 用于导航的资源插件 然而它只能处理一个容器,这对你没有真正的帮助。我会在您的 Bootstrap 方法中推荐类似的东西...然后,在您的布局中
Couple of things here...
First, to display navigation, use the appropriate helper. In your layout file...
See http://framework.zend.com/manual/en/zend.navigation.introduction.html and http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation
Secondly,
Zend_Application
has a resource plugin for navigation however it's only able to handle one container which doesn't really help you. I'd recommend something like this in your Bootstrap method...Then, in your layout