theme_book_navigation

Versions
4.6 – 5
theme_book_navigation($node)

Prepares both the custom breadcrumb trail and the forward/backward navigation for a node presented as a book page.

Related topics

Code

modules/book.module, line 442

<?php
function theme_book_navigation($node) {
  $path = book_location($node);

  // Construct the breadcrumb:

  $node->breadcrumb = array(); // Overwrite the trail with a book trail.
  foreach ($path as $level) {
    $node->breadcrumb[] = array('path' => 'node/'. $level->nid, 'title' =>  $level->title);
  }
  $node->breadcrumb[] = array('path' => 'node/'. $node->nid);

  if ($node->nid) {
    $output .= '<div class="book">';

    if ($tree = book_tree($node->nid)) {
      $output .= '<div class="tree">'. $tree .'</div>';
    }

    if ($prev = book_prev($node)) {
      $links .= '<div class="prev">';
      $links .= l(t('previous'), 'node/'. $prev->nid, array('title' => t('View the previous page.')));
      $links .= '</div>';
      $titles .= '<div class="prev">'. check_plain($prev->title) .'</div>';
    }
    else {
      $links .= '<div class="prev">&nbsp;</div>'; // Make an empty div to fill the space.
    }
    if ($next = book_next($node)) {
      $links .= '<div class="next">';
      $links .= l(t('next'), 'node/'. $next->nid, array('title' => t('View the next page.')));
      $links .= '</div>';
      $titles .= '<div class="next">'. check_plain($next->title) .'</div>';
    }
    else {
      $links .= '<div class="next">&nbsp;</div>'; // Make an empty div to fill the space.
    }
    if ($node->parent) {
      $links .= '<div class="up">';
      $links .= l(t('up'), 'node/'. $node->parent, array('title' => t('View this page\'s parent section.')));
      $links .= '</div>';
    }

    $output .= '<div class="nav">';
    $output .= ' <div class="links">'. $links .'</div>';
    $output .= ' <div class="titles">'. $titles .'</div>';
    $output .= '</div>';
    $output .= '</div>';
  }

  $node->body = $node->body.$output;

  return $node;
}
?>
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.