book_location

Versions
4.6 – 5
book_location($node, $nodes = array())

Given a node, this function returns an array of 'book node' objects representing the path in the book tree from the root to the parent of the given node.

Parameters

$node a book node object for which to compute the path

Return value

an array of book node objects representing the path nodes root to parent of the given node. Returns an empty array if the node does not exist or is not part of a book hierarchy.

▾ 5 functions call book_location()

book_block in modules/book.module
Implementation of hook_block().
book_export in modules/book.module
Menu callback; Generates various representation of a book page with all descendants and prints the requested representation to output.
book_location in modules/book.module
Given a node, this function returns an array of 'book node' objects representing the path in the book tree from the root to the parent of the given node.
book_next in modules/book.module
Fetches the node object of the next page of the book.
book_nodeapi in modules/book.module
Implementation of hook_nodeapi().

Code

modules/book.module, line 356

<?php
function book_location($node, $nodes = array()) {
  $parent = db_fetch_object(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.nid = %d'), $node->parent));
  if (isset($parent->title)) {
    $nodes = book_location($parent, $nodes);
    $nodes[] = $parent;
  }
  return $nodes;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.