You are here

function nodehierarchy_menu_node_prepare in Node Hierarchy 7.4

Implements hook_node_prepare().

File

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

Code

function nodehierarchy_menu_node_prepare($node) {
  if (!empty($node->nodehierarchy_parents[0])) {

    // Only the first item can have a menu item.
    if (empty($node->nodehierarchy_parents[0]->menu_link)) {
      if (isset($node->nid) && ($link = _nodehierarchy_menu_get_node_record_menu_links($node->nodehierarchy_parents[0]))) {
        $node->nodehierarchy_parents[0]->menu_link = $link;
      }
      else {
        $node->nodehierarchy_parents[0]->menu_link = _nodehierarchy_menu_default_menu_link(isset($node->nid) ? $node->nid : NULL);
      }
    }
  }
}