book_render

Versions
4.6 – 7
book_render()

Menu callback; prints a listing of all books.

Code

modules/book.module, line 579

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

  while ($page = db_fetch_object($result)) {
    // Load the node:
    $node = node_load(array('nid' => $page->nid));

    if ($node) {
      // Take the most recent approved revision, extract the page and check output:
      $node = book_content($node, TRUE);
      // Output the content:
      $output .= '<div class="book">';
      $output .= '<div class="title">'. l($node->title, 'node/'. $node->nid) .'</div>';
      $output .= '<div class="body">'. $node->teaser .'</div>';
      $output .= '</div>';
    }
  }

  drupal_set_title(t('Books'));
  print theme('page', $output);
}
?>
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.