You are here

function theme_book_navigation in Drupal 4

Same name and namespace in other branches
  1. 5 modules/book/book.module \theme_book_navigation()

Prepares the links to children (TOC) and forward/backward navigation for a node presented as a book page.

Related topics

1 theme call to theme_book_navigation()
book_nodeapi in modules/book.module
Implementation of hook_nodeapi().

File

modules/book.module, line 504
Allows users to collaboratively author a book.

Code

function theme_book_navigation($node) {
  $output = '';
  $links = '';
  if ($node->nid) {
    $tree = book_tree($node->nid);
    if ($prev = book_prev($node)) {
      drupal_add_link(array(
        'rel' => 'prev',
        'href' => url('node/' . $prev->nid),
      ));
      $links .= l(t('‹ ') . $prev->title, 'node/' . $prev->nid, array(
        'class' => 'page-previous',
        'title' => t('Go to previous page'),
      ));
    }
    if ($node->parent) {
      drupal_add_link(array(
        'rel' => 'up',
        'href' => url('node/' . $node->parent),
      ));
      $links .= l(t('up'), 'node/' . $node->parent, array(
        'class' => 'page-up',
        'title' => t('Go to parent page'),
      ));
    }
    if ($next = book_next($node)) {
      drupal_add_link(array(
        'rel' => 'next',
        'href' => url('node/' . $next->nid),
      ));
      $links .= l($next->title . t(' ›'), 'node/' . $next->nid, array(
        'class' => 'page-next',
        'title' => t('Go to next page'),
      ));
    }
    if (isset($tree) || isset($links)) {
      $output = '<div class="book-navigation">';
      if (isset($tree)) {
        $output .= $tree;
      }
      if (isset($links)) {
        $output .= '<div class="page-links">' . $links . '<br class="clear" /></div>';
      }
      $output .= '</div>';
    }
  }
  return $output;
}