如何使用 Zend_Navigation 实现面包屑导航
使用 Zend_Navigation 为 ZendFramework 应用程序实现面包屑的最佳实践/建议/技术是什么? 如何以及在哪里定义页面层次结构的最佳方法?
what are the best practices/suggestions/techniques to implement a breadcrumb for a ZendFramework application using Zend_Navigation? how and where is the best method to define the page hierarchy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
获取面包屑非常简单:
Zend_Navigation
键在Zend_Registry
中注册您在引导程序(或其他位置)中创建的Zend_Navigation
对象。 这样,该对象将被所有导航视图助手捕获。Zend_Application
样式引导,您可以简单地使用Zend_Application_Resource_Navigation
资源来设置导航。 只需在配置中设置resources.navigation.storage.registry = true
即可。然后你就可以简单地
在您的视图或布局脚本中。
谈到如何定义页面层次结构,我想说,如果您有一个更小、更静态的站点,您可以简单地在配置中定义页面(当使用新的
Zend_Application
-bootstrapping- 时)方法):或者,您可以使用额外的配置文件,或者您可以在前端控制器插件或操作助手中构建页面层次结构,例如,如果您有一个相当大的站点结构并且不想在每个站点上实例化整个站点地图要求。 这样,您还可以插入动态页面,例如,其标签是根据请求参数动态创建的。
Getting breadcrumbs is quite easy:
Zend_Navigation
object that you created in your bootstrap (or some other place) in theZend_Registry
with keyZend_Navigation
. That way the object will be caught up by all navigation view-helpers.Zend_Application
-style bootstrapping you can simply use theZend_Application_Resource_Navigation
resource to setup navigation. Just setresources.navigation.storage.registry = true
in your configuration.you can then simply
in your view or layout script.
Talking about how to define the page hierarchy, I'd say that if you have a somehow smaller and more static site, you can simply define the pages within your configuration (when using the new
Zend_Application
-bootstrapping-approach):Alternatively you could use an extra configuration file or you could build your page hierarchy in a front-controller plugin or an action helper, e.g. if you have a fairly large site structure and don't want to instantiate the whole sitemap on each request. That way you can also insert dynamic pages whose labels for example are dynamically created based on the request parameters.
我就此发表了 2 篇文章。
http:// blog.ekini.net/2009/05/25/zend-framework-making-the-built-in-breadcrumb-helper-work/
http://blog.ekini.net/2009/06/ 10/zend-framework-navigation-and-breadcrumbs-with-an-xml-file-in-zf-18/
两者都来自现实世界的经验。 对我来说,XML 文件更容易理解。
I made 2 posts on this.
http://blog.ekini.net/2009/05/25/zend-framework-making-the-built-in-breadcrumb-helper-work/
http://blog.ekini.net/2009/06/10/zend-framework-navigation-and-breadcrumbs-with-an-xml-file-in-zf-18/
Both are from real world experiences. For me, the XML file was easier to understand.