Customizing Superfish menus in your Fusion theme
The powerful Superfish menu system is provided by default to all Fusion sub-themes. Superfish is a jQuery plugin that takes an existing pure CSS drop-down menu and adds styling options to it. Being that it is styled purely through CSS, it gives the themer full control over how it appears all while maintaining the functionality. It also degrades nicely when JavaScript can’t be enabled and still presents the drop-down menu in a functional way.
By default the drop-down menu is set to fade in on hover, display vertically, and the hide when not hovered upon. You may want to change this behavior if you’re building your own Fusion theme. This functionality can be altered in a few ways by adding arrows to the menu items that have children (and set to expanded), change the delay for the drop-down display on hover, and even change the orientation of the menu by having it load horizontally rather than the default of vertically. There are numerous other changes that can be made to the menu system but these are some of the more common ones and I wanted to touch on those here.
Get the drop-downs to show immediately (no delay on hover)
This method involves editing the sub-theme’s script.js file and making changes to how the Superfish menu behaves. If your theme does not have a script file you can create one and load it through the theme’s .info file.
This bit of code goes into your theme’s script file and you will need to replace the “acquia_marina” text with your theme’s folder name. For example if your theme’s folder is named “sunshine_farms” your script should also read “sunshine_farms”. So be sure to change the “acquia_marina” to match your theme’s folder for this and all of the following examples.
Drupal.behaviors.acquia_marinaSuperfish = function (context) {
$("#primary-menu ul.sf-menu").superfish({
hoverClass: 'sfHover',
delay: 0,
animation: {opacity:'none',height:'none'},
speed: 'fast',
autoArrows: false,
dropShadows: false,
disableHI: true
}).supposition();
};Once the changes are made to your theme but sure to clear your site cache on the Performance page (/admin/settings/performance) so it reloads the theme files. You should now have a menu with a drop-down that displays instantly on hover rather than with a delay and fade in animation. The menu should look similar to this below:
Display arrows for menu items with children (and set to expanded)
This bit of code will make your menu items with children (and set to expanded) display an arrow after the menu item. This is a nice way to give a visual cue that there are sub menu items below the one that is currently visible. These changes also go in your theme’s script file. Again be sure to change the reference of “acquia_marina” to match that of your theme’s directory:
Drupal.behaviors.acquia_marinaSuperfish = function (context) {
$("#primary-menu ul.sf-menu").superfish({
hoverClass: 'sfHover',
delay: 250,
animation: {opacity:'show',height:'show'},
speed: 'fast',
autoArrows: true,
dropShadows: false,
disableHI: true
}).supposition();
};Horizontal drop-down menu
Technoli uses this method to display the drop-down menu horizontally rather than the default of vertically. This can be quite handy when you want a clean streamlined horizontal menu as it displays the second level horizontally and then the third level vertically. It gives it a nice touch that can easily be themed and used on your site.
Rather than editing your theme’s script file this change goes in your theme’s template.php. If there is no template.php with your theme you can create one and add this bit of code to it. Be sure to change the reference of “acquia_marina” to your theme’s directory name so it loads and works correctly.
function fusion_technoli_preprocess_page(&$vars) {
// Generate links tree & add Superfish class if dropdown enabled, else make standard primary links
$vars['primary_links_tree'] = '';
if ($vars['primary_links']) {
if (theme_get_setting('primary_menu_dropdown') == 1) {
$vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
$vars['primary_links_tree'] = preg_replace('/<ul class="menu/i', '<ul class="menu sf-menu sf-navbar', $vars['primary_links_tree'], 1);
}
else {
$vars['primary_links_tree'] = theme('links', $vars['primary_links'], array('class' => 'menu'));
}
}
}These simple changes can be applied to any Fusion based theme. That includes existing themes such as seen here with Acquia Marina, as well as themes available for sale on our site. As long as it’s a Fusion based sub-theme it will inherit the features of the Superfish menu and can be styled to suit your needs and styles.
If you have any other methods you have used to create Superfish drop-down menu variations or changes please let us know. I’d like to see some other examples than what we have done here and see some creative uses of the drop-down menu and how we can improve upon it. Please post your examples or questions/comments below.
This site runs on the Fusion theme for Drupal
Fusion is a powerful Drupal theme framework, with point-and-click layouts & built in styles for blocks, Views, and other modules. Download a Fusion theme for an instant, easy to configure design, or harness the power of Fusion in your own subtheme for a totally custom look.
And it’s free!

Comments (20)
tooltips
maybe you could make an option to disable (or override and style) the tooltip w/ link title because on the technoli demo it sometimes covers the submenu, making links hard or impossible to read.
Another thing I noticed is that you mentioned how the arrows are a nice visual indicator of submenus but you don't use them, while you do use them on the services menu on the left. The result was that I was looking for dropdown menus in the sidebar!
Thanks for this post. One
Thanks for this post.
One question: is there any solution to have superfish menus aligned centrally (not floated left or float right).
Arrows and centering primary menu
@ Peach - Actually one of our themes uses the arrows for the primary menu to show the ones with children menu items. Have a look the Clean Commerce demo site: http://cleancommerce.fusiondrupalthemes.com
It would also be nice to see the tooltip with the link title too, will have to look into that.
@ Drupal Theme Garden - This method might work for you on your theme as it worked for the Acquia Prosper theme to center the primary menu: http://drupal.org/node/616500
.supposition() is nor a function???
hi,
i added the funtion for show submenus immediately. It works but firebug says:
$("#primary-menu ul.sf-menu").superfish({hoverClass: "sfHover", delay: 0, animation: {opacity: "none", height: "none"}, speed: "fast", autoArrows: false, dropShadows: false, disableHI: true}).supposition is not a function
This breaks my js in my site.
What is the reason? is this function really not there?
If i remove supposition, then it does not work.
Supposition
The "supposition" should be valid as it can be removed to get different effects on your menu.
}).supposition();That is how it prints in the .js file so it should work. Try copying one of the scripts above to make sure the entire thing works on your site. Might have to clear your site cache on the Performance page to get it to work correctly without error.
Horizontal Dropdowns
Thank you for the informative post. I'm trying to get up to speed on creating Fusion sub themes and it answors some of my menu questions. Unfortunately, I'm being a bit thick in the head.
I'm trying to get horizontal dropdowns working with my fusion sub-theme and am not getting it. I've created a template.php file in my sub-theme folder and made sure the linux file & owner permissions are correct. I've pasted in the code example above and replaced "function fusion_technoli_preprocess_page" with "function messenger_theme_preprocess_page" (messenger_theme being the name of my sub-theme). Stopped and started Apache, cleared catches and still I get vertical dropdowns.
Any suggestions on troubleshooting this? Would it be silly to ask if this function is supposed to be called from someplace else and I need to add the line that calls it to another file?
Maybe missing php
@patwarn, my guess is you are missing the opening PHP statement in your theme's template.php file. It should start with this then the fuction:
<?phpSo it would end up looking like this:
<?php
function fusion_technoli_preprocess_page(&$vars) {
// Generate links tree & add Superfish class if dropdown enabled, else make standard primary links
$vars['primary_links_tree'] = '';
if ($vars['primary_links']) {
if (theme_get_setting('primary_menu_dropdown') == 1) {
$vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
$vars['primary_links_tree'] = preg_replace('/<ul class="menu/i', '<ul class="menu sf-menu sf-navbar', $vars['primary_links_tree'], 1);
}
else {
$vars['primary_links_tree'] = theme('links', $vars['primary_links'], array('class' => 'menu'));
}
}
}
Hope that helps!
new style for superfish
Hi.
I want to add a new style but nose Superfish menu where I change some property of the css or do want a semi-transparent effect for sub menus.
Supersubs integration
How can I integrate the supersubs plugin with superfish menus? I can see that the javascript is present in the Fusion Core but there doesn't seem to be an option to enable it anywhere.
AJAX?
I've got a menu with about 650 items on it total. It would vastly improve things if I didn't have to load the entire menu each time. I was wondering if anybody had a method of AJAX'ing a drupal menu with a fusion theme?
Trying to figure out how to
Trying to figure out how to stop submenu items from looping thru the animation over and over and over again. ie, on the demo if I move my mouse up and down over the red fruits,yellow fruits and green fruits menu items 50 times, it takes about 30 seconds for the menu to finally settle in where my mouse is. Isn't there some way to stop that?
IE7 Issue
We are developing a Fusion-based web site using the technique recommended in this article to generate horizontal dropdowns from the main menus. Everything works perfectly in FF, Safari, etc. but will not work in IK7 as the dropdowns never show.
IE7 is showing a JS error indication but I cannot understand what is going wrong.
Anyone have any suggestions?
Mike
Horizontal Menu Issue
We are still unable to make this work in IE7. Please - if anyone has any ideas I badly need a solution.
I would be willing to pay a reasonable price if someone can fix this issue with IE7.
Mike
Mike: please post in the
Mike: please post in the forums where someone might see your post who can help out.
The problem with ie7 is the
The problem with ie7 is the supposition() function, if you removit it works but does some undesired render..not so clean i think..
I dont really know what the subposition() function is for.
Best Regards,
Joao Garin
need to change text-coor in active state...
Hi All,
I'm using the Superfish horizontal menu in my website. This menu consists of horizontal secondary level menu and the vertical third level menu. The problem is when we move the mouse pointer from main menu to secondary level menu the color is changing and the same with the third level menu. Already i've tried out in the css file but there is of no use .Can anybody give me a suggestion regarding this.
Thanks in advance
change color of primary menu
Hi I am using the aquia prosper theme and am having trouble changing the primary menu to be black instead of clear when you click on it, and for the letters to be yellow instead of grey. how can I do that? also is there any way to make the borders of the menu be curved? thank you,Diana
cant get any of the
cant get any of the customizations to work. exactly which files/directories should the change be made to? im using acquia propser and been playing with this for the whole day and no progress. im getting lost on customization:
1. "themes script file" - should this be the fusion core script file or acquia_propser one??
2. "themes script file" - should this be the fusion core script file or acquia_propser one??
3. "theme’s template.php." - should this be the fusion core script file or acquia_propser one??
thank you very much for the customizations.
[FIXED] Problem with submenu navbar
Hi, I was having a problem with Superfish when enabled the nav-bar style. The problem was that if I use a classPath it works at 50%, because if I moved the mouse hover another menu link, the submenu just disappears.
Now, I'm commenting here because I've found a good solution, it was enough for me to do until step 4 (omitting step 1 and let it as in this post).
Maybe could work for somebody else: http://dtecht.blogspot.com/2011/01/superfish-menu-drupal-fusion-why-devi...
Regards.
not working for me, is there
not working for me, is there anything wrong here i cant spot it..
Drupal.behaviors.acquia_marinaSuperfish = function (context) {
$("#primary-menu ul.sf-menu").superfish({
hoverClass: 'sfHover',
delay: 0,
animation: {opacity 'none',height:'none'},
speed: 'fast',
autoArrows: false,
dropShadows: false,
disableHI: true
}).supposition();
};