book_tree

  1. drupal
    1. 4.7
    2. 5 book.module
Versions
4.7 – 5 book_tree($parent = 0, $depth = 3, $unfold = array())

Returns an HTML nested list (wrapped in a menu-class div) representing the book nodes as a tree.

▾ 2 functions call book_tree()

book_block in modules/book.module
Implementation of hook_block().
theme_book_navigation in modules/book.module
Prepares the links to children (TOC) and forward/backward navigation for a node presented as a book page.

Code

modules/book.module, line 618

<?php
function book_tree($parent = 0, $depth = 3, $unfold = array()) {
  $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND n.moderate = 0 ORDER BY b.weight, n.title'));

  while ($node = db_fetch_object($result)) {
    $list = isset($children[$node->parent]) ? $children[$node->parent] : array();
    $list[] = $node;
    $children[$node->parent] = $list;
  }

  if ($tree = book_tree_recurse($parent, $depth, $children, $unfold)) {
    return '<ul class="menu">' . $tree . '</ul>';
  }
}
?>