有没有办法在 drupal 中使用视图作为菜单?
我想要在主链接或辅助链接中将视图显示为菜单。
我搜索并查找了所有模块,但没有运气。
我应该手动构建这个功能==>构建一个模块?
提前致谢
I want to have a view displayed as a menu either in primarylinks or secondarylinks.
I searched and looked up all modules with no luck.
should I build this functionality manually ==> build a module?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主要和次要链接(事实上,所有菜单)使用主题函数(例如
theme_links()
。通过在视图中使用 HTML 列表样式,您可以非常接近相同的功能。您无法完全复制它,因为 Drupal 的菜单系统需要静态菜单项:它不处理查询结果等通配符。
也就是说,Drupal 的菜单系统是缓存的,并且仅根据请求重建(例如,通过手动添加菜单项、清除缓存等)。另一方面,视图是查询的包装器:每次访问视图,除非它也被缓存,否则它会运行查询来获取最新结果。
因此,如果您要将视图注入到菜单中,那么它只是第一次请求时的结果,任何后续更改都需要重建菜单。
我建议的解决方案将让您保留视图的功能,将其主题化为看起来像菜单,并避免菜单系统的警告。
Primary and secondary links (in fact, all menus) are rendered as unordered lists of links using a theme function like
theme_links()
. You can get pretty close to the same functionality by using the HTML List style within a view.You can't duplicate it exactly because Drupal's menu system requires static menu items: it doesn't handle wildcards like the results of a query.
That is, Drupal's menu system is cached, and is only rebuilt upon request (e.g. by adding a menu item manually, clearing the cache, etc.) A view, on the other hand, is a wrapper to a query: every time you access the view, unless it too is cached, it runs a query to get the latest results.
So, if you were to inject a view into a menu, it'd only be the results at the time of first request, and any subsequent changes would require rebuilding the menu.
The solution I suggested will let you keep the functionality of the view, theme it to look like a menu, and avoid the caveats of the menu system.