Use menus in Drupal 7? You need Menu block module.

by John Albin Wilkins

Drupal 7.0 is out! And while we managed to get all the critical bugs fixed before it was released, there's still a handful of major bugs that we weren't able to fix. One of those bugs affects Drupal's menus: Custom menus never receive an active trail. Oops.

Hey! If this link is active, why isn't it expanded?
Custom menus in Drupal 7.0

So if you are using a menu you created yourself with the "Add menu" link on the Menu administration page (admin/structure/menu), that menu won't work properly in Drupal 7.0. If you visit any of the top-level pages in that menu, none of them will expand to show you their child links. This is really bad.

There's also a several related symptoms of this bug. Did you just enable the Contact module and create a link to it underneath another item in your Main menu? Well, it won't ever be in the active trail because the Contact-module-provided "Contact" link that is hiding in the Navigation menu will only ever be the active trail. And if you want to provide two different paths to the same item in two different menus? That, too, won't fly under Drupal 7.0.

Fortunately, Menu block module version 7.x-2.0 was released this week with a work-around for this bug. So if you want to ensure your menus work properly under Drupal 7.0, make sure you download the new version of Menu block.

Open source solutions come from many, many people

I'm just trying to get the word out about this bug as its not particularly easy to understand or diagnose. And, while I've spent a few hours trying to fix this problem, there were many others that deserve mention.

Our own Bec White was the first to diagnose this bug after Greg Leroux first spotted it. With code from Bec, Matt Farina, and Commerce Guys' Damien Tournoud, I managed to craft (or more accurately, hack) a work-around for this bug: #1017122 and #1017142.

And, yes, I am working with others on a proper patch for Drupal core. Hopefully, the fix will be incorporated into Drupal 7.1. In the meantime, I hope you'll discover how awesomely flexible the Menu block module is and keep it around even after the core bug is fixed.

Its important to share your ideas, code and problems in an Open Source community. Because that's how things get done.

Comments

Just wanted to say thank you (and others who helped with this fix)! I tried Drupal 7 and fought two hours with menus.. I just tought that I didn't get those. I actually even installed Menu block, but it was few days before this fix.

And yes, I do like the menu block!

Thank you for the tip...was wondering what I'm doing wrong : )
I believe one of the next releases will include general fix.

Thanks again.

Thank you for this wonderful module! (and also your patience with me) :)

Let's try hard to get menu_block into core for D8 :)

PS: Still want to talk with you about the future of some modules/projects - just ping me when you have time!

Great to see a fix for this bug. One more obstacle to converting to D7 gone! Fixing this should help get D7 implemented on even more sites. Thanks!

Hi,

The default secondary-menu for Drupal 7 hides the links when one is not logged in, and enables them (View account, and log out) when one is logged in. However, when you add links to this menu, there's no option to hide/view based upon authentication or uid... Any suggestions on how this is done without hacking the core module?

Thanks!

So far the simplest way to do this is a ! $logged_in for non-authed users

<?php
   
global $user;
          if (!
$logged_in) { ?>

      <?php if ($secondary_menu): ?>
      <div id="secondary-menu" class="navigation">
        <?php print theme('links__system_secondary_menu', array(
         
'links' => $secondary_menu,
         
'attributes' => array(
           
'id' => 'secondary-menu-links',
           
'class' => array('links', 'inline', 'clearfix'),
          ),
         
'heading' => array(
           
'text' => t('Secondary menu'),
           
'level' => 'h2',
           
'class' => array('element-invisible'),
          ),
        ));
?>

    </div> <!-- /#secondary-menu -->
    <?php endif; ?>   
       
          <?php }    ?>

<?php
             
if ($logged_in) {
              }
           
?>

hi,
I installed the newest version and created a menu with one sublink, after installing the menu. Then I moved the menu-block to one of my sidebars.
It still didn´t show any sublinks. I tried that also with some other themes, including garland and other standard drupal themes.

Is Drupal 7 still that buggy?
I´m already thinking about sticking with Version 6 for at least one more year.

Thanks for any help,
Marc

Wish I found your article before I spent an entire morning troubleshooting this headache.

@hkazemz & @marc2010 for whatever reason I needed to restart my server to get it all work - hope that helps

Are you kidding me??

This is such a big issue that Drupal 7 should not even be available until its fixed. The module menu_block didn't fix it either.

Upgrade to 7 from 6.2 has been a nightmare and is seriously making me consider dropping drupal.

does somebody can show me how to use this module in Drupal 7?
what are required? how to create a menu with it's items? any tutorials? i have read Better Know a Module: Menu Block (Part I) and the Part II but i don't get it. this is my first try using Drupal. i am a newbie on CMS.
the case is pretty simple, if i have these menu tree structure:
- countries
--- UK
--- US
--- Japan
- languages
--- English
--- Japanese
then i don't want the top menus (countries and languages) act as links. i mean they are just static text at all. then their items act as the real links.
i do need help on it, thank you for any response.