• I have a site built in Drupal 7 with the navigation hard-coded in template.tpl.php. How do I go about switching this over to use the menu module instead?

  • I've already have the menu recreated in the site's main menu. How do I make my theme display the Drupal menu rather than my hard-coded one?

  • Is it correct to copy my current theme, create a new theme from that, swap out the hard-coded menu with some PHP code (where do I get that?), adjust the styles, and then activate the new theme?

One thing particular to my theme is I have menu drop-downs (secondary menus) that display when you mouseover the primary-level nav using JavaScript image swaps. I would have to recreate this menu in CSS.

3 Answers 3


You only need to create a new theme if the site in question is in production and you are not able to set up a development version of the site make your changes to the existing theme. In that case, you will want to create a copy of your theme with a different theme name and make sure to update the name of your MYTHEME.info file as well as any function names in your theme's template.php file.

Whether or not you do the above, the rest of the process should be the same either way.

  • Create a backup of the template file where the menu is hardcoded.
  • Create a block region where the menu currently is. There are two parts to this step: First you will need to add the following line to the MYTHEME.info file to let it know that the region exists:

    regions[menu] = Menu

    You'll want to make sure that there is not already a region with the same machine name. If there is, you may want to change it to something like:

    regions[menu_top] = Top Menu

    Next, you'll need to replace the hard-coded HTML for the menu with the code to display the region, something like:

    <?php if ($menu): ?>
    <?php print $menu ?>
    <?php endif; ?>
  • Clear caches. This forces the theme registry to be rebuilt and your new region will be show up.

  • Add the menu block to the newly created region. Visit /admin/structure/blocks and find the block that is automatically created for the menu that you have recreated using Drupal's menu system and drag it into the "Menu" region that you just created.
  • Superfish. This is one of the better drop-down menu solutions, IMO. You'll want to follow the module instructions for getting it set up. This module creates additional blocks that you can assign your menu to. This will alter the previous step because you will add the superfish block and then assign the menu in the superfish block settings.
  • Profit!

1) I suggest checking out the Nice Menus and Superfish modules that should be relatively good choices for creating drop-down menus in Drupal. There's a brief comparison of them here. They should have enough documentation available to help with the implementation as well. If needed you can search the web for additional modules which may be more suitable depending of your requirements (like DHTML Menu, JQuery menu).

2) If you need customization to a degree where these modules are more of a hindrance than help then check out the Menu Block module and the Menu API page to help you get the menu displayed and then add your custom css/javascript to it.

You don't necessarily need to create a new theme for these changes until you want to preserve the version with the hard-coded menu as a separate theme. In most cases it's probably enough to do the changes in a development environment and when it's ready move the changes to the production site.

  • If you don't need anything else that is in your template.php file, you can just rename your current template.php file to something like template.php.old (just in case you need it later) and create another blank template.php file. Don't forget to clear your caches.


  • If you have other code in your template.php file that you need you can comment out or delete the lines that pertain to your menu. (I recommend commenting them out, just in case) Again don't forget to clear your caches.

As far as drop down menus, I have used and really like the Superfish Module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.