“How To” add Dropdown Submenus for Drupal 7

2 replies [Last post]
Lee.Reeves
Offline
Last seen: 8 years 24 weeks ago
Joined: 2011-09-02

You can find the following YouTube video courtesy of Brian Vanaski, which will walk you through replacing the native Drupal menu with a Nice Menu containing drop down menu items: http://www.youtube.com/watch?v=oPP6LNLeGcg. The audio is poor but Brian does a good job providing step-by-step instructions.

Following is a summary of the steps. If you need more details, please check out the video referenced above.

STEP 1: Place a copy of the Bartik Theme in the "Sites/All/Themes" folder.
STEP 2: Change the name of the Bartik folder to a unique name (sub theme).
STEP 3: Change the name of the Bartik.info file (use the same name from Step 2).
STEP 4: Change all occurrences of "bartik" in the “bartik.info” and “template.php” file to your new sub theme name from Step 2.
STEP 5: Install and configure "Nice Menus" and "Menu Block;" make sure to enable Menu Block, Menu Block Export and Nice Menus.
STEP 6: Create your menu structure with both parent and child menu items -- make sure you have checked "Show as expanded" for each parent menu containing submenus.
STEP 7: Replace lines 127 to 138 in the "Page.Tpl.php" (found in the Templates folder) with the following code courtesy of MRadcliffe at: http://drupal.org/node/240831.
<?php
// id, direction, depth should have the values you want them to have.
$menu = theme('nice_menus', array('id' => 0, 'direction' => 'down', 'depth' => 1, 'menu_name' => 'main-menu', 'menu' => NULL));
print $menu['content'];
?>
STEP 8: Configure the CSS for Nice Menus to fit the look and feel of your website.

As a novice Drupal user, I found this process extremely useful. Hopefully you will too. Again, a special THANK YOU to Brian Vanaski and MRadcliffe for doing all the hard work.

If you have a simpler solution, please feel free to comment.

jenlampton
Offline
Last seen: 7 years 11 weeks ago
Joined: 2012-02-07
Do not copy the Bartik theme

In STEP 1 You should NOT make a copy of a core theme.

Creating copies of files that may be updated in future versions of Drupal core is tricky, since you'll need to keep checking all those files for updates, and re-applying changes manually when they occur.

It is far better to create a sub-theme of Bartik. To do that, create a folder inside sides/all/themes with the name of your theme. Then create a file inside that folder with the same name, and a .info extension, as follows:
mytheme/mytheme.info

You'll need to add a few lines to your .info file, as follows:

name = My Custom Theme
description = A sub-theme of Bartik.
core = 7.x
engine = phptemplate
base_theme = bartik

By specifying that this theme is a sub-theme of Bartik, it will use all the files from the Bartik theme, unless specifically overridden, thus decreasing the likelihood that you'll need to maintain updates to the theme yourself.

Copy themes/bartik/templates/page.tpl.php into sites/all/themes/mytheme and continue with STEP 5, above.

(Also, the menu_block module is not necessary for this use of nice_menus for your primary links.)

Chris Shattuck
Offline
Last seen: 9 weeks 6 days ago
Joined: 2009-08-16
Hey Jen! Thanks for popping

Hey Jen! Thanks for popping in, and great response! I just noticed your comment wasn't published and have gone ahead and posted it. Looking forward to seeing you soon. :)

Cheers,
Chris

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:


Loading...
Contact us

Below are the supported keyboard shortcuts for our video player.

space
Start / stop video
shift
Go to next video
shift
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
1...9
Jump to a percentage (2 is 20%, for example)
f
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
$29
1 month
$156
6 months
10% off
$276
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
user
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.