What the heck are Superfish and Suckerfish?

Published December 15th, 2009 under General

Many people get confused when working with our WordPress menu plugins and CSS generator as to what exactly “Suckerfish” is and what the difference is between it and “Superfish“. Most of you will never need to understand the difference, but for those of you keen to dive in and either custom build your own menu or tinker around under the hood of our plugins, here is a brief run-down on what they are and how they work.

Suckerfish

The original Suckerfish javascript code was posted on A List Apart by Patrick Griffiths and Dan Webb. As outlined in our :hover pseudo class post, it simply adds support for the same effect as the :hover pseudo class in Internet Explorer 6 and older browsers.

The following code is based on the most popular form of the Suckerfish script, the “Son of Suckerfish” by HTML Dog. This code works with any unordered list with an ID of #suckerfishnav.

sfHover = function() {
var sfEls = document.getElementById("suckerfishnav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

The following code is more suitable for situations in which you need support for multiple dropdown menus on the same page as it works on any unordered list with a class of .sf-hover (ie: you can’t have two menus with the same ID therefore this class system works better in such situations).

function sfHoverEvents(sfEls) {
var len = sfEls.length;
for (var i=0; i
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(" sfhover", "");
}
}
}
function sfHover() {
var ULs = document.getElementsByTagName("UL");
var len = ULs.length;
for(var i=0;i
if(ULs[i].className.indexOf("sf-menu") != -1)
sfHoverEvents(ULs[i].getElementsByTagName("LI"));
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);</code>

Superfish

Superfish is a plugin for the jQuery javascript framework. Unlike the simple Suckerfish methods outlined above, Superfish adds many more features to your menu than just :hover pseudo class support in IE6.

Some features of the Superfish jQuery plugin are:

  • Timed delay on mouseout to be more forgiving of mouse-piloting errors.
  • Animation of sub-menu reveal. The animation speed is customisable
  • Keyboard accessibility. Tab through the links and the relevant sub-menus are revealed and hidden as needed.
  • Supports the hoverIntent plugin. Superfish automatically detects the presence of Brian Cherne’s hoverIntent plugin and uses its advanced hover behaviour for the mouseovers (mouseout delays are handled by Superfish regardless of the presence of hoverIntent).
  • Indicates the presence of sub-menus by automatically adding arrow images to relevant anchors. Arrows are fully customisable via CSS.

To see a demo of the Superfish plugin in action, hover over the menu of the Dunedin Ice Hockey Association.

HTML

We will post another blog post soon outlining best practices and how to create your own custom HTML for your menu.

Other scripts

There are many other alternative scripts out there too. If you have any favourites, please post a link to them in the comments.

:hover pseudo class and evil IE!

Published December 10th, 2009 under General

There seems to be some confusion amongst the users of our site about exactly why our WordPress menu plugins include javascript files, yet work fine without it, so here is an explanation. If none of this makes sense to you and you are using one of our WordPress menu plugins, don’t worry! Our plugins handle all of this stuff for you automatically so you don’t need to.

:hover pseudo class

It has been known for a long time that it is possible to create dropdown menus purely using nested HTML blocks and the :hover CSS pseudo class. Unfortunately, although almost every single web browser added support for this feature a long time ago, Microsoft decided to drag it’s heels and waited a horrendously long time before eventually launching Internet Explorer 7 (IE7) which finally had support for the :hover pseudo class. Many users still do, and likely will for many years to come, use Internet Explorer 6 (IE6) as their browser. There are many, many reasons why they shouldn’t be using it, but unfortunately some users either refuse to upgrade, don’t know how or are simply stuck on an old school corporate intranet without the ability to upgrade. For this reason a slew of methods via javascript have been created to add support for the :hover pseudo class into IE6 and older browsers. This is the reason that all of our WordPress menu plugins use javascript, they work without the javascript in all modern browsers, but for Internet Explorer 6 and older browsers they use a javascript to allow the menus to still operate.

Suckerfish and conditionals

The suckerfish script is the standard script used to add the same effect as the :hover pseudo class in IE6. In the past, it was common place to simply load the file for every page load, however now that IE6 does not have a 90%+ hold on the browser market place it is advisable to only serve the scripts to those browsers that need it. The best way to serve the file only to those older browsers is to place a link to an external script via IE conditional comments like this:

<!--[if lte IE 7]>
<script type="text/javascript" src="suckerfish_ie.js"></script>
<![endif]-->

You could alternatively include the code directly on the page itself, but this increases the page load slightly for all browsers rather than just limiting it to the old clunkers like IE6. With conditionals you can save quite a few lines of code on every page load.

Once you have a Suckerfish script running on your page, you can apply a class (usually .sfhover for most scripts) to the CSS and use that for IE6 instead of the :hover pseudo class.

Why we need to use IE7, not IE6 conditionals – another Microsoft screwup

You may have noticed that the above code is written to serve the Suckerfish script to IE7 and older browsers, despite IE7 already featuring support for the :hover pseudo class. Previously this would have been considered silly as it would only slow down the loading of a page in IE7. However Microsoft being Microsoft, have decided to add a compatibility mode into Internet Explorer 8 (IE8) which it says “will behave just like IE7″. However this is entirely incorrect as IE8 compatibility mode does not support the :hover pseudo class at all. Most of the time this would not matter, but if a user is browsing your site and for whatever reason decides to click the “compatibility mode” button, they would not be able to use your menu if there was no javascript being served to it, and since it considers itself to be IE7 it will not follow IE6 conditional comments. For this reason, we must now place the script inside IE7 conditionals as above.

Coming soon will be a blog post about alternatives to the Suckerfish script, the best versions to use and how to setup your custom HTML.

Aqua Vaccinium WordPress theme

Published February 23rd, 2008 under Templates

The “Aqua Vaccinium” WordPress theme was originally intended for use on a clients site, but they have since decided to go with a red theme and use Dreamweaver (ick!) instead of WordPress, so we have decided to release this theme to you for free.

Aqua Vaccinium features a smooth blue and green theme and has a prominent Suckerfish dropdown menu built in (no plugin needed).

Aqua Vaccinium WordPress theme

Live Demo

Visit our WordPress theme demo site to see Aqua Vaccinium in action.

Download

Aqua Vaccinium download

Bugs/feature requests

If you find a bug or would like an extra feature which isn’t present in the standard Aqua Vaccinium theme, feel free to leave a comment in our themes forum.

If you require any customisations specific to your site, please get in touch via our contact form.

Theme files

We’ve tried to keep the theming as simple as possible to allow for easy customisation. There are only five template files, plus images, javascript and css files. I’ve included the original build file for the logo (PSD format), so you can edit it to match your own site name.

The main dropdown menu is set to display categories by default, but you can insert other pages into your dropdown if you like (leave a post in our themes forum if you need help with this).

The blue section (below the main menu) displays either the blog description or the category description depending on what page you are on. If the blog or category description is missing, this will be left blank.

Naming

The word Aqua came from the mixture of the blue and green tones of the design. The name Vaccinium is the genus for a variety of berries including blue berries which we baked a pie for in honour of the new theme.

more information »

WordPress Dropdown Menu Plugin

Published January 14th, 2008 under Plugins

Note: This plugin has been superceded by the ‘PixoPoint Menu Plugin‘.

This plugin generates the code necessary to create a Son of Suckerfish WordPress dropdown menu.

Download

The plugin is available for download here … Suckerfish WordPress Plugin

Installation

Add the following code wherever you want the dropdown to appear in your theme (usually header.php) and activate the plugin in your admin panel.

This code adds a button for your home page and dropdowns for your Pages, Archives, Categories and Blogroll.
<?php if (function_exists('suckerfish')) {suckerfish();} ?>

Customisation

You can modify the look of your dropdown by using our new Online Suckerfish Dropdown CSS Generator. The generator has been designed with this plugin in mind, so just copy and paste the CSS code from the generator to the plugins options page.

Credits

Thanks to Patrick Griffiths and Dan Webb for their article which we used as a model for the CSS used in this plugin. And thanks to Miriam Schwab for writing the blog post which motivated us to create it.

Support

For support, please visit the dropdown menus board in our support forum. Please note that many new features are available in the ‘Multi-level Navigation Plugin‘ so you should check that out before asking any questions about this plugin.