diff --git a/menu_block.module b/menu_block.module index 738dac3..86de8f9 100644 --- a/menu_block.module +++ b/menu_block.module @@ -684,16 +684,23 @@ function menu_tree_prune_tree(array &$tree, $level, array $parent_item = NULL, $ for ($i = 1; $i <= MENU_MAX_DEPTH && $parent_item["p$i"] != '0'; $i++) { $plid = $parent_item["p$i"]; $found_active_trail = FALSE; + // Examine each element at this level for the ancestor. foreach ($tree as $key => &$value) { if ($tree[$key]['link']['mlid'] == $plid) { menu_block_set_title($tree[$key]['link']); - // Prune the tree to the children of this ancestor. + $found_active_trail = TRUE; - if (!empty($include_parent) && $plid != $parent_item['plid']) { + + // Check if this ancestor is indeed the parent of our starting level. + $is_parent = $plid != $parent_item['plid'] && $parent_item['depth'] == $i; + + if (!empty($include_parent) && $is_parent) { + // Prune the tree to this ancestor. $tree = array($key => $tree[$key]); } else { + // Prune the tree to the children of this ancestor. $tree = $tree[$key]['below'] ? $tree[$key]['below'] : array(); } break;