You are here

function _nodehierarchy_set_menu_order in Node Hierarchy 5

Same name and namespace in other branches
  1. 6 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 973
A module to make nodes hierarchical.

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_mid = _nodehierarchy_get_menu($nid, $parent_mid)) {
      db_query("UPDATE {menu} SET weight = %d WHERE mid = %d", $order_by, $child_mid);
      return TRUE;
    }
  }
  return FALSE;
}