有没有办法在 drupal 中使用视图作为菜单?

发布于 2024-09-14 13:37:51 字数 102 浏览 12 评论 0原文

我想要在主链接或辅助链接中将视图显示为菜单。

我搜索并查找了所有模块,但没有运气。

我应该手动构建这个功能==>构建一个模块?

提前致谢

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

油焖大侠 2024-09-21 13:37:51

主要和次要链接(事实上,所有菜单)使用主题函数(例如 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文