You are here

function _site_map_books in Site map 5

Same name and namespace in other branches
  1. 8 site_map.module \_site_map_books()
  2. 6.2 site_map.module \_site_map_books()
  3. 6 site_map.module \_site_map_books()
  4. 7 site_map.module \_site_map_books()

Render books

1 call to _site_map_books()
theme_site_map_display in ./site_map.module

File

./site_map.module, line 366
Original author: Nic Ivy Now maintained by by Fredrik Jonsson fredrik at combonet dot se

Code

function _site_map_books() {
  if (module_exists('book') && ($nids = variable_get('site_map_show_books', array()))) {
    $title = t('Books');
    $description = '<div class="description">' . t("Books at %sn.", array(
      "%sn" => variable_get('site_name', 'Drupal'),
    )) . '</div>';
    $result = db_query(db_rewrite_sql('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = 0 AND n.status = 1 AND n.moderate = 0 AND n.nid IN (%s) ORDER BY b.weight, n.title'), implode(',', $nids));
    while ($node = db_fetch_object($result)) {
      $book_display .= '<h3>' . l($node->title, 'node/' . $node->nid) . '</h3>';
      $book_display .= book_tree($node->nid, 5, array(
        variable_get('site_map_books_expanded', 1) ? TRUE : '',
      ));
    }
    if ($book_display) {
      $output = theme('box', $title, $description . $book_display);
    }
  }
  return $output;
}