You are here

function _nodehierarchy_set_menu_order in Node Hierarchy 6

Same name and namespace in other branches
  1. 5 nodehierarchy.module \_nodehierarchy_set_menu_order()

Reorder the child menus of the given parent.

1 call to _nodehierarchy_set_menu_order()
_nodehierarchy_normalize_child_order in ./nodehierarchy.module
Normalize the order of the children of the given node.

File

./nodehierarchy.module, line 1042

Code

function _nodehierarchy_set_menu_order($parent, $nid, $order_by) {

  // Check here for any menu item for the given node whose parent menu item points
  // to the node's parent. This helps prevent messing with menus which have been
  // taken out of the automatically created hierarchy.
  // This is not possible for top level items, so we rearrange them anyway, since
  // this is usually the desired behaviour.
  if ($parent_menu = _nodehierarchy_get_parent_menu($parent, $nid)) {
    if ($child_menu = _nodehierarchy_get_child_menu($nid, $parent_menu['mlid'])) {
      $link = menu_link_load($child_menu['mlid']);
      $link['weight'] = $order_by;
      menu_link_save($link);
      return TRUE;
    }
  }
  return FALSE;
}