You are here

function book_build_active_trail in Drupal 6

Build an active trail to show in the breadcrumb.

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

File

modules/book/book.module, line 619
Allows users to structure the pages of a site in a hierarchy or outline.

Code

function book_build_active_trail($book_link) {
  static $trail;
  if (!isset($trail)) {
    $trail = array();
    $trail[] = array(
      'title' => t('Home'),
      'href' => '<front>',
      'localized_options' => array(),
    );
    $tree = menu_tree_all_data($book_link['menu_name'], $book_link);
    $curr = array_shift($tree);
    while ($curr) {
      if ($curr['link']['href'] == $book_link['href']) {
        $trail[] = $curr['link'];
        $curr = FALSE;
      }
      else {
        if ($curr['below'] && $curr['link']['in_active_trail']) {
          $trail[] = $curr['link'];
          $tree = $curr['below'];
        }
        $curr = array_shift($tree);
      }
    }
  }
  return $trail;
}