Menu Minipanels in Adaptivetheme - Instant Mega Menu for Any Menu Item

Menu Minipanels is a very cool little module that allows you to attach a mini panel to a menu item, which then pops open when you hover the menu item - aka instant mega menu!

A drawback of the current Menu Minipanels module is that it only works with Drupal cores Main and Secondary menus - not to worry, this tutorial is going to show you how to make it work with any menu. This is very important for many themes that do not use Drupal cores magic menus (because they suck) and prefer to use the "blocks and regions" concept. All of our commercial and open source themes work like this, because it allows much more flexibility, for example to use Menu Block module, Superfish and many other modules to slice, dice and transform menus any way you want.

hook_page_alter()

Sounds pretty scary, right? Well in a way it is, however it gives us the power to insert the code we need to make Menu Minipanels use our custom menu, which is awesome. I'm not going to muck around here, this is so easy we can avoid some long winded explanation and just go strait for the code.

You can do this in a module, or in your theme. Drupal 7 allows themes to use hook_page_alter(), so in your template.php file add the following code block - you only need to do two things:

  1. Change the name of the function to match your theme name, and...
  2. Change the name of the menu to match your menu name

<?php
/**
* Implements hook_page_alter().
*
* Add our own menus for Menu Mini Panels.
*
* This function does two things:
* 1. Prepare the links.
* 2. Build the output.
*
* Rename to match your module or theme, then add your menu name.
*/
function themeName_page_alter(&$page) {

 
// Replace "menu-my-menu-name" with your menu name
 
$menu = menu_navigation_links('menu-my-menu-name');

 
// Don't change anything below here...
 
if (!empty($menu)) {
   
menu_minipanels_prepare_links($menu);
  }

 
$output = '';
  foreach (
menu_minipanels_panels(NULL, NULL) as $mlid => $minipanel_name) {
   
$output .= '<div class="menu-minipanels menu-minipanel-' . $mlid . '">' . _menu_minipanels_render_panel($minipanel_name) . '</div>';
  }

  if (!empty(
$output)) {
   
$page['page_bottom']['menu_minipanels'] = array(
     
'#markup' => $output,
    );
  }
}
?>

And that's about it, you might need to clear you cache also. Now you can add your Menu Minipanel to any menu item in the menu you specified.

Submitted by Jeff Burnz on

Comments

Sung Eun Kim's picture

Just got it working!

You're awesome! All I needed to do was copy & paste into template.php and substitute theme name & menu name and clear cache. Can't believe how fast you are in providing support. Million thanks,

warrenbuffet2's picture

Thanks!

Thanks for clearing that up...great support

Nathan's picture

Using Menu Mini Panels successfully!

Hi there,

I'm using one of your themes and was hoping to use Menu Mini Panels, but I'm really finding the basic implementation of the module a real nightmare - I have no idea why.

Is there a tutorial, or resource that you know that would lead me step-by-step through a basic use case?

Jeff Burnz's picture

Nathan - not sure what you

Nathan - not sure what you are asking for, do you mean a step by step tutorial for using Menu Minipanels module or implementing the code in this article?

Nathan's picture

Hi there.

Hi there.

Thanks for the reply. I was just wondering if during your implementation of Menu Mini Panels you had come across a resource that helped you out... getting it going.

I'm using your Corolla 7.x-2.2 theme (which I love btw) and when I get the module going and put a menu in the mini panel, it is always open by default. I can never get it to be collapsed so that you have to mouseOver to see the sub menu items.

I have put the qtip jQuery plugin in two different locations - one suggested in the module homepage, and one in the module readme.txt, but neither seem to work.

So what I'm saying is... did you have this issue, and do you know of a helpful article/tutorial that might supply soe additional information? I can't find anything that out there with the usual Googling!

btw the menu is 'main', so I don't think that I need your code above, but I could be wrong about that because I'm pulling Taxonomy Terms into 'main' with the Taxonomy Menu module.

Thanks.

watchbayg's picture

Wall Art

You can browse a wide range of quality art work at Arts My Passion. Categories of Wall art include Abstract art, Modern art, Contemporary art, African Art, Asian art and much more. Secure online ordering and free shipping within the USA and Canada. Visit http://www.artsmypassion.com today!
Wall Art

abstractart007's picture

Abstraact Art

You can browse a wide range of quality art work at Arts My Passion. Categories of Abstract art include Abstract art, Modern art, Contemporary art, African Art, Asian art and much more. Secure online ordering and free shipping within the USA and Canada. Visit http://www.artsmypassion.com today!
Abstract Art

Add new comment