Zend_Navigation_Page_Mvc 和片段标识符
我在我的网站上使用 Zend_Navigation
。大多数项目是 Zend_Navigation_Page_Mvc
而不是 Zend_Navigation_Page_Uri
。我知道我可以轻松添加 片段标识符 到 Zend_Navigation_Page_Uri
项,但这不是我正在寻找的优雅解决方案。 这篇文章,但它们扩展了 URL 帮助器并且不影响导航。
我已经使用子类 Zend_View_Helper_Navigation_Menu
来呈现菜单。也许有一种方法可以使用 htmlify()
函数来完成此任务?
I use Zend_Navigation
on my site. Most of the items are Zend_Navigation_Page_Mvc
and NOT Zend_Navigation_Page_Uri
. I know that I can easily add a fragment identifier to a Zend_Navigation_Page_Uri
item, but that's not the elegant solution I'm looking for. There are a couple of solutions on this post, but they extend the URL helper and don't affect navigation.
I already use a sub-classed Zend_View_Helper_Navigation_Menu
to render the menus. Maybe there's a way to accomplish this with the htmlify()
function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终将一个名为
fragment
的属性添加到传递给Zend_Navigation
的页面数组,然后在我的子类Zend_View_Helper_Navigation_Menu::htmlify().这是我的 htmlify() 代码:
I ended up adding a property called
fragment
to the page array passed intoZend_Navigation
and then checking for it in my sub-classedZend_View_Helper_Navigation_Menu::htmlify()
. Here is myhtmlify()
code:linked to post 不会影响导航,因为 Zend_Navigation_Page_Mvc 使用 Zend_Controller_Action_Helper_Url 而不是 Zend_View_Helper_Url。您必须覆盖 Zend_Controller_Action_Helper_Url::url() 然后 将您的助手添加到助手代理 以使其影响 Zend_Navigation。
在我的实现中,我使用 '_fragment' 选项/参数来帮助防止名称冲突:
然后,在我用来配置 Zend_Navigation 的 XML 文件中,我创建一个 _fragment 参数:
The solutions in the linked to post don't affect navigation because Zend_Navigation_Page_Mvc uses Zend_Controller_Action_Helper_Url and not Zend_View_Helper_Url. You have to override Zend_Controller_Action_Helper_Url::url() and then add your helper to the helper broker for it to affect Zend_Navigation.
In my implementation, I use a '_fragment' option/param to help prevent name conflicts:
Then, in the XML file I use to configure Zend_Navigation, I create a _fragment param: