Community Documentation

Customize breadcrumbs to include parent level book terms

Last updated August 26, 2009. Created by glass.dimly on September 3, 2008.
Edited by bekasu, jhodgdon. Log in to edit this page.

Currently, in Drupal 5x, top-level book page parents have no breadcrumb whatsoever, not even a link to the main or home page. The following code adds a breadcrumb that includes the title of the page as well as a link home.

Find the code in your page.tpl.php file that looks something like this:

<?php if($breadcrumb) { ?>
  <div id="breadcrumb">
    <div class="wrapper">
      <?php print $breadcrumb; ?>
    </div>
  </div>
<?php } ?>

Replace that code with this:
<?php if($breadcrumb) { ?>  //if the node already has a breadcrumb, print the normal one
  <div id="breadcrumb">
    <div class="wrapper">
      <?php print $breadcrumb; ?>
    </div>
  </div>
  <?php }
  elseif (!
$is_front) { ?>
//checks to see if the page is not the front page, and if it isn't, prints the site name as a link to home, a chevron, and then the title of the current page
    <div id="breadcrumb">
    <div class="wrapper">
      <a href="<?php print base_path(); ?>"><?php print $site_name; ?></a> » <?php print $title ?>
    </div>
  </div>
<?php } ?>

About this page

Drupal version
Drupal 5.x
Audience
Designers/themers

Theming Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here