Drupal分层菜单
我是 Drupal 的新手,我还在构建一个 N 层分层菜单,我想根据当前的 $node->path
来显示部分。
菜单看起来像这样 -
---Top
------菜单-1
---------菜单-2
------------菜单-3
------菜单-4
---------菜单-5
------------菜单6
等等
每个菜单也是 Drupal 中的页面内容类型,因此如果 $node-path 是 /top/menu-3,我希望能够仅获取 Menu-1 及其所有子项。当我这么说时,听起来我似乎需要一些 xpath。
I'm new to Drupal, and I'm also building an N-tier hierarchical menu that I want to display sections at time based on the current $node->path
.
The menu looks like this -
---Top
------Menu-1
---------Menu-2
------------Menu-3
------Menu-4
---------Menu-5
------------Menu-6
etc etc etc
Each menu is also a page content type in Drupal, so if the $node-path is /top/menu-3, I want to be able to grab only Menu-1 and all its children. As I'm saying this, it almost sounds like I need some xpath in here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用菜单块模块,您可以创建一个块来显示菜单,就像Drupal的内置菜单一样菜单块,但从特定深度开始。在您的示例中,您可以创建一个块来显示从深度 2 开始的菜单(菜单 1 和菜单 4)并跟随活动项(即当前查看页面的菜单项)。查看菜单 1、菜单 2 或菜单 3 时,该块将显示菜单 1 及其子菜单。查看菜单 4、菜单 5 或菜单 6 时,该块将显示菜单 4 及其子菜单。当查看顶部时,菜单将为空。
此外,它还适用于非节点页面。
With the Menu Block module, you can create a block to display a menu just like the Drupal's menu built-in menu block but starting at a specific depth. In your example, you can create a block to display your menu starting at depth 2 (Menu 1 and Menu 4) and following the active item (ie. the menu item for the currently viewed page). When viewing Menu 1, Menu 2 or Menu 3, the block will display Menu 1 and its children. When viewing Menu 4, Menu 5 or Menu 6, the block will display Menu 4 and its children. And when viewing Top, the menu will be empty.
Also, it works with non-node pages.
我不完全确定你想要做什么,但它似乎是 节点层次结构 模块可能是你的解决方案。
使用此模块,您可以创建一个节点层次结构,它可以自动生成分层菜单、分层路径等。
i'm not entirely sure what you're trying to do, but it seems like the node hierarchy module could be your solution.
with this module you can create a node hierarchy which can automatically result in hierarchical menus, hierarchical paths, etc.