Zend_Navigation 的自定义渲染
我将导航 XML 文件与我的 Zend Framework MVC 应用程序结合使用。
顶级菜单呈现在布局的顶部。生成它的代码如下所示:
$this->navigation()->menu()->renderMenu(null,array('maxDepth' => 0));
这将自动呈现我已在顶部菜单中设置样式的链接的无序列表。 现在,我想利用所有内置 Zend_Navigation 优点(MVC 和 ACL 集成)但使用自定义标记来渲染子菜单(以渲染活动容器树)。我会通过插入以下内容来做到这一点:
$this->navigation()->menu()->renderSubMenu();
事实上,我有一组非常具体的标记,我需要用它们来呈现它。它是如此的截然不同,我认为我无法设计一个无序列表来适应我想要的演示文稿。
有没有一种简单的方法(或者如果需要的话可以复杂一点;)来自定义子菜单?
I am using a navigation XML file in conjunction with my Zend Framework MVC app.
A top level menu is rendered at the top of my layout. The code to produce it looks like this:
$this->navigation()->menu()->renderMenu(null,array('maxDepth' => 0));
This will automatically render an unordered list of links that I have styled into my top menu.
Now, I want to render the submenu (to render the active container tree) taking advantage of all the built-in Zend_Navigation goodness (MVC and ACL integration) but with custom markup. I would do this by inserting this:
$this->navigation()->menu()->renderSubMenu();
In fact, I have a very specific set of markup that I need to render this with. It is so drastically different I do not think I could style an unordered list to accomodate my desired presentation.
Is there a simple way (or complicated if need be ;) to customize a submenu?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看我的这个答案: 让 Zend_Navigation 菜单正常工作通过 jQuery 的 Fisheye
总结,您可以创建一个用于导航的视图并循环浏览页面,并使用页面方法创建自定义标记。据我所知,目前导航没有类似装饰器的支持。
Check out this answer of mine: Getting Zend_Navigation menu to work with jQuery's Fisheye
Summarized, you create a view for the navigation and loop through the pages and use the page methods to create custom markup. As far as I know, there's no decorator-like support for Navigation currently.
Typeoneerror 让我走上了正轨,这是我最终使用的代码:
在layout.phtml中:
在sidemenu.phtml中:
工作得像一个魅力,将其作为答案供其他人查找。
Typeoneerror put me on the right track, here is the code I ended up using:
In layout.phtml:
In sidemenu.phtml:
Worked like a charm, leaving this as an answer for someone else to find.