You are here

function nodehierarchy_menu_set_menu_active_tail in Node Hierarchy 7.4

Set the active menu to the nearest visible parent.

1 call to nodehierarchy_menu_set_menu_active_tail()
nodehierarchy_menu_node_view in nodehierarchy_menu/nodehierarchy_menu.module
Implements hook_node_view().

File

nodehierarchy_menu/nodehierarchy_menu.module, line 519
Create menu items for a node based on the Node Hierarchy.

Code

function nodehierarchy_menu_set_menu_active_tail($node) {

  // Check if the current item has an active menu item.
  $trail = menu_get_active_trail();
  if ($last = array_pop($trail)) {
    if ($last['link_path'] != $_GET['q']) {

      // Set the menu posution to the nearest ancestor which has a menu.
      if ($menu_link = _nodehierarchy_menu_get_nearest_ancestor_menu_link($node->nid)) {
        menu_tree_set_path($menu_link['menu_name'], $menu_link['link_path']);
      }
    }
  }
}