book_print_recurse
- Versions
- 4.6
book_print_recurse($parent = '', $depth = 1)
Code
modules/book.module, line 638
<?php
function book_print_recurse($parent = '', $depth = 1) {
$result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND b.parent = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $parent);
while ($page = db_fetch_object($result)) {
// Load the node:
$node = node_load(array('nid' => $page->nid));
// Take the most recent approved revision:
if ($node->moderate) {
$node = book_revision_load($node, array('moderate' => 0, 'status' => 1));
}
if ($node) {
// Output the content:
if (node_hook($node, 'content')) {
$node = node_invoke($node, 'content');
}
// Allow modules to change $node->body before viewing.
node_invoke_nodeapi($node, 'view', $node->body, false);
$output .= '<h1 id="'. $node->nid .'" name="'. $node->nid .'" class="book-h'. $depth .'">'. check_plain($node->title) .'</h1>';
if ($node->body) {
$output .= '<ul>'. $node->body .'</ul>';
}
$output .= book_print_recurse($node->nid, $depth + 1);
}
}
return $output;
}
?>Login or register to post comments 