--- menutree.pages.old.inc 2009-01-17 10:17:03.000000000 +0100 +++ menutree.pages.inc 2009-01-17 10:52:59.000000000 +0100 @@ -56,31 +56,48 @@ function menutree_display_all() { * - MENUTREE_TITLE_BODY: Include the title of the menu in the body of the page. */ function menutree_display($menu, $title_display = MENUTREE_TITLE_PAGE) { + $output = ''; - /* - $output = ''; - - $title = variable_get('menutree_title_'. $menu['menu_name'], ''); - drupal_set_title(check_plain(!empty($title) ? $title : $menu['title'])); - // Output custom intro text. $intro = variable_get('menutree_intro_text_'. $menu['menu_name'], ''); + $description = ''; if (!empty($intro)) { - $output .= check_markup($intro, FILTER_FORMAT_DEFAULT, FALSE); + $description = check_markup($intro, FILTER_FORMAT_DEFAULT, FALSE); } - $tree = menu_tree_output(menu_tree_all_data($menu['menu_name'])); - $output .= theme('menutree_page', $tree); - - return $output; -*/ - - $output = ''; + // Getting the tree first - if no title set in admin than we collect the titles from the tree parents + $link = menu_tree_all_data( $menu['menu_name'] ); + // Getting the array of the needed menuitems in array + $neededTree = array_slice( arg(), 2 ); + $titles = array( $menu['title'] ); + // If we have other arguments than narrowing the menu tree + if ( count($neededTree) > 0 ) { + while ( count($neededTree)>0 ) { + $currentNeededIndex = array_shift( $neededTree ); + $linkKeys = array_keys( $link ); + // We need to run through the links because of the hidden items... + for( $i=0; $i<=$currentNeededIndex; $i++ ){ + if ( $link[ $linkKeys[$i] ]['link']['hidden'] ) { + $currentNeededIndex++; + } + } + $titles[] = $link[ $linkKeys[$currentNeededIndex] ]['link']['title']; + if ( gettype($link[ $linkKeys[$currentNeededIndex] ]['below']) == 'array' ) { + $link = $link[ $linkKeys[$currentNeededIndex] ]['below']; + } + else { + $link = array(); + } + } + } + $tree = menu_tree_output( $link ); + // Making the title // The title could be displayed in various ways. + // Modified: if no title was set then it'll display the titles breadcrumb-like from the tree parents $title = variable_get('menutree_title_'. $menu['menu_name'], ''); if (!$title) { - $title = $menu['title']; + $title = implode(' ยป ', $titles); } $title = check_plain($title); @@ -91,18 +108,14 @@ function menutree_display($menu, $title_ $tree_title = ''; if ($title_display & MENUTREE_TITLE_BODY) { $tree_title = $title; - } - - // Output custom intro text. - $intro = variable_get('menutree_intro_text_'. $menu['menu_name'], ''); - $description = ''; - if (!empty($intro)) { - $description = check_markup($intro, FILTER_FORMAT_DEFAULT, FALSE); - } - - $tree = menu_tree_output(menu_tree_all_data($menu['menu_name'])); + } + + $output .= theme('menutree_page', $tree_title, $description, $tree); + + // Cleaning up the possibly big array + unset($link); - return theme('menutree_page', $tree_title, $description, $tree); + return $output; } /**