If I have some nodes that are of type book, how can I go through them in a php script and tell which is the root? thanks
-
1can you elaborate your question?– Ashish DeynapFeb 11, 2017 at 6:16
1 Answer
You can try to build the menu tree for your book. Book nodes do not have direct parents. The relationship is defined by the menu structure.
This will give you the structure of the book menu.
$book = $node->book;
$tree = menu_tree_all_data(book_menu_name($book['bid']));
-
-
This function is part of the book.module file. It should be available after Drupal bootstrapped. Where exactly are you putting your code?– schlickiFeb 13, 2017 at 16:27