-1

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.

Sreejith Sasidharan
  • 1,318
  • 5
  • 25
  • 46
  • How are you setting the node parent or node children ? – João Guilherme Jan 04 '11 at 11:18
  • i think the words primary and secondary best suite the nodes. The primary page is selected from the Parent item: when we create a page from the admin.I want to get the list of secondary pages from the ID of a primary page. – Sreejith Sasidharan Jan 04 '11 at 13:38

1 Answers1

2

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.

Oswald
  • 31,254
  • 3
  • 43
  • 68