&$value) { if ($tree[$key]['link']['in_active_trail']) { $found_active_trail = TRUE; // If the active trail item has children, examine them. if ($tree[$key]['below']) { // If we are pruning to the active menu item's level, check if this // is the active menu item by checking its children. if ($level == 'active') { foreach ($tree[$key]['below'] AS $child_key => &$value) { if ($tree[$key]['below'][$child_key]['link']['in_active_trail']) { // Get the title for the pruned tree. menu_block_set_title($tree[$key]['link']); $tree = $tree[$key]['below']; // Continue in the pruned tree. break 2; } } // If we've found the active item, we're done. break 2; } // Set the title for the pruned tree. menu_block_set_title($tree[$key]['link']); // If we are pruning to the children of the active menu item, just // prune the tree to the children of the item in the active trail. $tree = $tree[$key]['below']; // Continue in the pruned tree. break; } // If the active menu item has no children, we're done. else { if ($level == 'child') { $tree = array(); } break 2; } } } } while ($found_active_trail); }