From 888fd6415f8868578a8a6b24d7ad1e7b624b59d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Mon, 1 Oct 2007 09:49:14 +0000 Subject: #179474 by JirkaRybka and pwolanin: proper depth counting for menu tabs when parents are missing inbetween --- includes/menu.inc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/includes/menu.inc b/includes/menu.inc index dce681fde..5f1bd6c3b 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -1100,6 +1100,9 @@ function menu_local_tasks($level = 0, $return_root = FALSE) { // Find all tabs below the current path. $path = $router_item['path']; + // Tab parenting may skip levels, so the number of parts in the path may not + // equal the depth. Thus we use the $depth counter (offset by 1000 for ksort). + $depth = 1001; while (isset($children[$path])) { $tabs_current = ''; $next_path = ''; @@ -1122,14 +1125,16 @@ function menu_local_tasks($level = 0, $return_root = FALSE) { } } $path = $next_path; - $tabs[$item['number_parts']]['count'] = $count; - $tabs[$item['number_parts']]['output'] = $tabs_current; + $tabs[$depth]['count'] = $count; + $tabs[$depth]['output'] = $tabs_current; + $depth++; } // Find all tabs at the same level or above the current one. $parent = $router_item['tab_parent']; $path = $router_item['path']; $current = $router_item; + $depth = 1000; while (isset($children[$parent])) { $tabs_current = ''; $next_path = ''; @@ -1164,8 +1169,9 @@ function menu_local_tasks($level = 0, $return_root = FALSE) { } $path = $next_path; $parent = $next_parent; - $tabs[$item['number_parts']]['count'] = $count; - $tabs[$item['number_parts']]['output'] = $tabs_current; + $tabs[$depth]['count'] = $count; + $tabs[$depth]['output'] = $tabs_current; + $depth--; } // Sort by depth. ksort($tabs); -- cgit v1.2.3