3

I have nid of a book page. I need the nid of the parent and nid of all direct and indirect childs.

How to retrieve the parent and child IDs?

  • Please elaborate it I am not able to understand it properly. Is book node is some kind of node_reference or what? – Deepak Kumar Apr 29 '13 at 8:06
3

This is for Drupal 6 but might also apply to Drupal 7. The hierarchy of a book is created with a menu. When you have the node object in $node you'll get the menu link id of the parent in $node->book['plid']. You can then load the corresonding node with menu_link_load().

As for the children you have to get the menu that represents the hierarchy of your book with menu_tree_all_data($node->book['menu_name']) and then go through that menu to fetch the links you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.