function _nodehierarchy_swap_menu_order in Node Hierarchy 5
Reorder the child menus of the given parent.
File
- ./
nodehierarchy.module, line 991 - A module to make nodes hierarchical.
Code
function _nodehierarchy_swap_menu_order($parent, $a, $b) {
// Swap the weights of two items whose weights have beens swapped.
// Only do so if the items have menu items which are children of their parent node's menu item.
if ($parent_mid = _nodehierarchy_get_menu($parent)) {
$a_menu = db_fetch_array(db_query("SELECT mid, weight FROM {menu} WHERE pid = %d AND path = 'node/%d'", $parent_mid, $a));
$b_menu = db_fetch_array(db_query("SELECT mid, weight FROM {menu} WHERE pid = %d AND path = 'node/%d'", $parent_mid, $b));
if ($a_menu && $b_menu) {
// Swap the menu items.
db_query("UPDATE {menu} SET weight = %d WHERE mid = %d", $a_menu['weight'], $b_menu['mid']);
db_query("UPDATE {menu} SET weight = %d WHERE mid = %d", $b_menu['weight'], $a_menu['mid']);
return TRUE;
}
}
return FALSE;
}