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.
Asked
Active
Viewed 2,119 times
-1
-
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 Answers
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.
- Deduce the
mlid
(menu link id) of the parent by examining thelink_path
s of the returned items. - Find the menu link items that have the found
mlid
asplid
(parent link id). - 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