You are here

function nodehierarchy_set_breadcrumbs in Node Hierarchy 6

Same name and namespace in other branches
  1. 5 nodehierarchy.module \nodehierarchy_set_breadcrumbs()
  2. 6.3 nodehierarchy.module \nodehierarchy_set_breadcrumbs()
  3. 6.2 nodehierarchy.module \nodehierarchy_set_breadcrumbs()
  4. 7.4 nodehierarchy.module \nodehierarchy_set_breadcrumbs()
  5. 7.2 nodehierarchy.module \nodehierarchy_set_breadcrumbs()

Set the breadcrumbs and active menu to reflect the position of the given node in the site hierarchy.

Parameters

$node: The current node

$add_node: Whether we want the current node in the breadcrumb (eg: for the children tab)

2 calls to nodehierarchy_set_breadcrumbs()
nodehierarchy_nodeapi in ./nodehierarchy.module
Implmentation of hook_nodeapi().
nodehierarchy_view_children in ./nodehierarchy.module
Display the children tab.

File

./nodehierarchy.module, line 783

Code

function nodehierarchy_set_breadcrumbs($node, $add_node = FALSE) {

  // Place the given node.
  $breadcrumb = array();
  $parent = $node;
  $homepage = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
  while (@$parent->nid) {
    $item = menu_get_item("node/" . $parent->nid);
    if (($add_node || $parent->nid != $node->nid) && $item['href'] != '<front>' && $item['href'] != $homepage) {
      $breadcrumb[] = l($parent->title, "node/" . $parent->nid);
    }
    $parent = node_load($parent->parent);
  }
  $breadcrumb[] = l(t('Home'), '<front>');
  drupal_set_breadcrumb(array_reverse($breadcrumb));
}