重置 Zend_Navigation 状态
我目前正在构建一个应用程序,我可以通过多种方式访问同一控制器。
例如:
Presenters -> access controller user/index with param user_type : presenters Attendees -> access controller user/index with param user_type : attendees
在我的导航 .ini 中,我定义了两个路径(我删除了标签、模块和 ACL 以方便阅读):
dashboard.pages.presenter.controller = "user"
dashboard.pages.presenter.action = "index"
dashboard.pages.presenter.pages.create.controller = "user"
dashboard.pages.presenter.pages.create.action = "create"
dashboard.pages.presenter.pages.edit.controller = "user"
dashboard.pages.presenter.pages.edit.action = "edit"
dashboard.pages.attendee.controller = "user"
dashboard.pages.attendee.action = "index"
dashboard.pages.attendee.pages.create.controller = "user"
dashboard.pages.attendee.pages.create.action = "create"
dashboard.pages.attendee.pages.edit.controller = "user"
dashboard.pages.attendee.pages.edit.action = "edit"
我遇到的问题是,当我转到与会者部分时,显示的面包屑是一份给主持人。我知道它按预期工作,但我正在寻找一种方法来根据 URL 参数 user_type
将正确的“节点”设置为活动状态。
使用这个:
$page = $this->view->navigation()->findOneByLabel($label);
if ($page) {
$page->setActive();
}
我已经能够将页面设置为活动状态,但我正在寻找一种将 Zend_Navigation
状态“重置”为无的方法。
I am currently building an application where I have multiple ways to access the same controller.
E.g.:
Presenters -> access controller user/index with param user_type : presenters Attendees -> access controller user/index with param user_type : attendees
In my navigation .ini I have defined both paths (I removed the label, the module and ACL to ease the reading):
dashboard.pages.presenter.controller = "user"
dashboard.pages.presenter.action = "index"
dashboard.pages.presenter.pages.create.controller = "user"
dashboard.pages.presenter.pages.create.action = "create"
dashboard.pages.presenter.pages.edit.controller = "user"
dashboard.pages.presenter.pages.edit.action = "edit"
dashboard.pages.attendee.controller = "user"
dashboard.pages.attendee.action = "index"
dashboard.pages.attendee.pages.create.controller = "user"
dashboard.pages.attendee.pages.create.action = "create"
dashboard.pages.attendee.pages.edit.controller = "user"
dashboard.pages.attendee.pages.edit.action = "edit"
The issue I am having is that when i go to the attendee section, the breadcrumb that is displayed is the one for the presenters. I understand that it work as intended, but I am looking for a way to set the right "node" active based on the URL param user_type
.
Using this :
$page = $this->view->navigation()->findOneByLabel($label);
if ($page) {
$page->setActive();
}
I have been able to set a page to active, but I am looking for a way to "reset" the Zend_Navigation
state to none.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要我让你正确地将其放入你的 Bootstrap 中并复制我为你编写的控制器插件。我还没有测试如果没有为视图设置导航会发生什么。最好测试一下。顺便说一句,使用不同路由的相同页面对于搜索引擎优化来说并不好。
引导程序:
控制器插件:
As long as I got you right put this in your Bootstrap and copy the controller plugin I wrote for you. I did not test yet what happens if no navigation was set to the view. Better test that. By the way having equal pages using different routes is not good in terms of seo.
Bootstrap:
Controller Plugin: