You are here

function nodehierarchy_set_breadcrumbs in Node Hierarchy 5

Same name and namespace in other branches
  1. 6.3 nodehierarchy.module \nodehierarchy_set_breadcrumbs()
  2. 6 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)

1 call to nodehierarchy_set_breadcrumbs()
nodehierarchy_nodeapi in ./nodehierarchy.module
Implementation of hook_nodeapi().

File

./nodehierarchy.module, line 740
A module to make nodes hierarchical.

Code

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

  // Place the given node.
  $menu[] = array(
    "path" => "node/" . $node->nid,
    'title' => $node->title,
    'type' => MENU_NORMAL_ITEM,
  );
  $homepage = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
  $parent = $node;

  // Push the antecedants onto the breadcrumb/active menu stack (but not the homepage).
  while ($parent->parent) {
    $parent = node_load($parent->parent);
    if ("node/" . $parent->nid != $homepage) {
      $menu[] = array(
        "path" => "node/" . $parent->nid,
        'title' => $parent->title,
        'type' => MENU_NORMAL_ITEM,
      );
    }
  }

  // Set the menu location and breadcrumb.
  menu_set_location(array_reverse($menu));
}