Jun 07

Simple and easy drop down (Suckerfish) menus for Drupal 6

Sun, 07/06/2009 - 21:32 — You

For the Arthemia theme I was trying to find a nice and simple way to add suckerfish menus. However most solutions involved either magic incantations or jquery plugins. A little too much.

Just as I was about to give up hope, I had a look at the Multiflex-3 theme for drupal and its implementation of suckerfish menus. Finally, something that was simple and easy to follow! No js either, which IMO is a good thing.

The actual code in the template.php file from multiflex-3 that you will need to add/work with is:

<?php
/**
* Return a cascade primary links.
* Clone implementation from user_block().
*
* @return
*   a themed cascade primary links.
*/
function phptemplate_primary() {
 
$output = '<div id="primary-links-region">';
 
$output .= menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
 
$output .= '</div>';
  return
$output;
}
?>

You will also need to add the following inpage.tpl.php instead of the normal primary_links code (where you want to show the drop down):

  <?php if (isset($primary_links)) : ?>
    <?php print phptemplate_primary($primary_links); ?>
  <?php endif; ?>

Nice and simple. wahay!

(I did rename the function from phptemplate_primary() to arthemia_primary(). Because I could.)

Thankyou multiflex-3 for this simple solution.