Expanded menus don't stay expanded

eliza411 - September 25, 2006 - 16:25
Project:MultiFlex theme
Version:4.7.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I'm actually not sure if this is a bug or a feature, but it seems like a bug.

When you select the advanced configuration choice of Expanded for a menu, I expect that it will be expanded regardless of theme, but in multiflex it collapses. I looked for a tag that I could use to style them, but there's no indicator they were ever marked to be expanded.

I've looked at ways to fix it, but I don't see how. Any pointers would be greatly appreciated. It's a beautiful theme.

#1

PipSqueak - January 3, 2007 - 13:18

I'm having this problem too.

#2

pathscollide - April 2, 2007 - 20:38
Status:active» needs review

Hi. Sorry not to post a proper patch but I'm still very much a newbie. The problem comes from a theme override function in template.php. The code for this function was adapted from the nice_menus module and doesn't take into account menus set to be always expanded.

Here is a fix that works:

I added these lines:

<?php
function phptemplate_menu_tree($pid=1) {
 
// Code adapted from the nice_menus module
  // generates nested <ul> <li> lists
 
$menu = menu_get_menu($pid);
 
$output = '';
  if (
$menu['visible'][$pid]['children']) {
    foreach (
$menu['visible'][$pid]['children'] as $mid) {
     
// Check whether the menu type is set; if so, assign it to $type; if not set $type to NULL
     
$type = isset($menu['visible'][$mid]['type']) ? $menu['visible'][$mid]['type'] : NULL;
      if (
count($menu['visible'][$mid]['children']) > 0) {
       
$output.= "<li>".menu_item_link($mid);
       
// Check if the menu item is in the active trail OR if the menu type is "always expanded"
       
if ((menu_in_active_trail($mid)) || ($type & MENU_EXPANDED)) { // only output children if they should be seen
         
$output.= "<ul>";
         
$tmp = phptemplate_menu_tree($mid);
         
$output.= $tmp;
         
$output.= "</ul>";
        }
       
$output.= "</li>";
      }
      else {
       
$output.= "<li>".menu_item_link($mid)."</li>";
      }
    }
  }
  return
$output;
}
?>

#3

ZaphMann - June 27, 2007 - 02:35

I'm only 5 days into Drupal and on v. 5 - but isn't this handled by dhtml_menu-5.x-0.7.tar?

 
 

Drupal is a registered trademark of Dries Buytaert.