I have a subnav using menu block and on some pages with children it will expand the menu to show the children, but on some it won't. From what I can tell, there is no reason or setting why it should work on some pages and not on others.

You can see the site here: drupal.mcgreevyprolab.com Look at Press Printing Services. Only one link will show its children. When I'm on the child page the menu is expanded.

Comments

museumboy’s picture

Status: Active » Needs work

I figured this out: this module does not work correctly with Menu Trail by Path enabled.

mausolos’s picture

I actually am having a similar issue, but I don't have Menu Trail by Path on my system at all. My problem is that none of my child links are showing up at all, even though I've checked the various boxes in menu and the settings page for the menu block that should tell them to display expanded.

The modules I have enabled that might have anything to do with menus or blocks are:

admin_menu
admin_menu_toolbar
menu
menu_block
menu_block_export
borealis_sb (borealis module)
block
blockify

mausolos’s picture

This appears that it may be an issue with the theme I'm using, Aurora. When switching to Bartik and getting the settings as close as possible relative to the theme, I was able to see the expanded menu.

snappermorgan’s picture

For me, it was the Bootstrap 3.0 theme. I discovered that in one of its core include files it was only rendering the submenu with a depth of 1.

The file is bootstrap/theme/menu/menu-link.func.php. I added my own hook_menu_link override in my template.php file and removed the check on menu depth and all my submenus magically appeared.

modstore’s picture

Issue summary: View changes

Thanks for the feedback snappermorgan, I had the same exact issue.

skadu’s picture

I can confirm snappermorgan and modstore's findings, Bootstrap 3 has an issue here.

Eric At NRD’s picture

I struggled with this issue today. Fortunately, there is a simple fix for it:
https://www.drupal.org/node/1850194#comment-8551799

rcodina’s picture

Thanks @snappermorgan for your suggestion. it works for me.

rcodina’s picture

MrPeanut’s picture

@snappermorgan — I'm having the same issue. Would you be able to share your overrides?

mrcdrx’s picture

I have the same problem. I have set a fixed parent menu item, and I want to show all children of that menu item. I've checked 'Expand all children of this tree', and set maximum depth to 'Unlimited'. When I'm logged in, the entire menu expands. However, when I'm viewing the site as a Anonymous user, only the first menu item with children expands, and the rest stays collapsed. I don't have Menu Trail by Path installed or enabled

Edit: Nevermind: some of nodes connected to the menu items had viewing access blocked by Content Access, so the menu-items weren't show. D'oh!

bhawanac’s picture

I was facing the same problem with book navigation.

#4 Worked for me.
Thanx

bhawanac’s picture

I was facing the same problem with book navigation.

And for that patch #4 worked for me.
Thanx!

Jabastin Arul’s picture

Only "Bootstrap" theme has a problem. And #4 patch working perfectly

Jabastin Arul’s picture

Please use this code:

function themename_menu_link__menu_block($variables) {
return theme_menu_link($variables);
}

Please put that code on template.php file

cptnobvious’s picture

I'm using the bootstrap theme and also wasn't seeing any sub-submenu items (depth 2) rendered when using menu_block
Adding this to my template.php fixed it. It's mostly code from menu-link.func.php with an extra else statement to catch things with a greater depth than 1. Hope it helps someone.


//function to get child submenus to render properly for us in menu_block
function MYTHEME_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';
  $options = !empty($element['#localized_options']) ? $element['#localized_options'] : array();
  $title = empty($options['html']) ? check_plain($element['#title']) : filter_xss_admin($element['#title']);
  $options['html'] = TRUE;
  $href = $element['#href'];
  $attributes = !empty($element['#attributes']) ? $element['#attributes'] : array();
  if ($element['#below']) {
    if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) {
      $sub_menu = drupal_render($element['#below']);
    }
    elseif ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] == 1)) {
      unset($element['#below']['#theme_wrappers']);
      $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>';

      $title .= ' <span class="caret"></span>';
      $attributes['class'][] = 'dropdown';
      $options['attributes']['data-target'] = '#';
      $options['attributes']['class'][] = 'dropdown-toggle';
      $options['attributes']['data-toggle'] = 'dropdown';
    }else{
      $sub_menu = '<div class="submenuitem"> '.drupal_render($element['#below']).'</div>' ;
    }
  }
  return '<li' . drupal_attributes($attributes) . '>' . l($title, $href, $options) . $sub_menu . "</li>\n";
}

luciano.baraglia’s picture

#16 is the only that worked for me...thanks dude... (great username BTW)

Jabastin Arul’s picture

Status: Needs work » Needs review
Vasantha Raja’s picture

#15 worked like a charm.