在drupal中使用父nodeid查找所有子节点

发布于 2024-10-10 16:14:42 字数 73 浏览 0 评论 0原文

如何使用 drupal 中特定父节点的 id 查找所有子节点?我尝试了 drual_menu_tree ,但它仅显示当前页面的子级。

how do i find all the child nodes using the id of a particular parent node in drupal? I tried drual_menu_tree , but it displays only the child of the current page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

东风软 2024-10-17 16:14:42

Drupal 节点之间没有父子关系。从你的评论来看,我怀疑你在谈论菜单。

如果是这样,请查看 menu_tree_all_data。这将为您提供菜单中的链接。

  1. 通过检查返回项的 link_path 来推断父级的 mlid(菜单链接 id)。
  2. 查找将找到的 mlid 作为 plid(父链接 ID)的菜单链接项。
  3. 从这些项目中,过滤掉指向节点的项目(通过再次检查它们的 link_path)。

这在 PHP 中是相当麻烦的。定制的 SQL 查询可能更快。您必须查询 {menu_links} 表;它包含我正在谈论的 mlidplidlink_path

There is no parent-child relation amongst Drupal nodes. From your comment, I suspect you are talking about menus.

If so, have a look at menu_tree_all_data. This gives you the links you have in your menu.

  1. Deduce the mlid (menu link id) of the parent by examining the link_paths of the returned items.
  2. Find the menu link items that have the found mlid as plid (parent link id).
  3. From those items, filter out the ones that point to a node (by examining their link_path again).

This is quite cumbersome to do in PHP. A customized SQL query is probably faster. You would have to query the {menu_links} table; it contains the mlid, plid and link_path I was talking about.

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