PDA

View Full Version : how to INCLUDE a Suckerfish dropdown menu ?



amoelle
03-26-2005, 06:44 PM
Now, here's a wicked one !!

I've been working on a website, where I use Suckerfish dropdown menus (please visit http://www.htmldog.com/articles/suckerfish/example/)

My problem is, that I don't want to maintain identical lists (the menustructure) in top of every page on the website

ie.
<ul id="nav">
<li id="first">
<div><a href="">Band</a></div>
<ul style="position: absolute; left: 0px; top: 18px; width: 108px">
<li><a href="pages/jp.htm">Bouzouki, guitar,vocal</a></li>
<li><a href="pages/lv.htm">Fiddle, vocal</a></li>
<li><a href="pages/sk.htm">Bodhrn, percussion, vocal</a></li>
<li><a href="pages/ml.htm">Sean Ns Step, vocal</a></li>
<li><img src="graphics/mclip5.jpg" width="100" height="65"/></li>
</ul>
</li>
<li>
<div><a href="">Music</a></div>
....
</li>
</li>
</ul>

etc

instead, I'd like to keep the ordered list in one file, ie menu.htm, and then include it in the 20 webpages.

....I don't want to use frames...
....I've tried Iframe, but the dropdown 'hides' when outside the iframe....
....<layer> is only suitable for NS......

... I'm about to give up :eek:

Can anyone give me a hint on this ?? :confused:

/Anne

jscheuer1
03-26-2005, 07:08 PM
I looked at that suckerfish menu awhile back. It not only was amusing but, also looked quite effective. The only idea that comes to mind is to write your menu as a document.write script and put it in the body of each page. An easy way to convert is at Convert HTML to JavaScript (http://www.htmlshop.com/tools/html2java2.asp). Once you have that code, take out the opening and closing tags, line breaks and extra spaces (two or more spaces replace with one space) and save it to a file, say 'myfshmnu.js'. Then in the body of each page at the point where you want the menu displayed put this:

<script src="myfshmnu.js" type="text/javascript"></script>
Added Later:
You can do a similar thing with the suckerfish script itself but, here the method is easier. Simply save the script as is but, without the beginning and ending tags, to a file, say 'suckerfish.js'. Put this in the head of each document that uses it:

<script src="suckerfish.js" type="text/javascript"></script>

jscheuer1
03-26-2005, 11:16 PM
I tried this out here and even included the style as an external stylesheet. It worked fine but a more refined example of what 'myfshmnu.js' could look like is:

with(document){
writeln('<HR><UL id=nav><LI id=first><DIV><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Overview</A></DIV><UL><LI><IMG height=27 alt=Remora ');
writeln('src="the Suckerfish_files/remora4.gif" width=100></LI> <LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Classification</A> </LI><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Physcial Characteristics</A></LI><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Habitat</A></LI><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Lifestyle</A></LI><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Evolution</A></LI><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Distribution</A></LI></UL></LI><LI><DIV><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Species</A></DIV><UL><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Ceylonese remora</A></LI> <LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Remora remora</A></LI> <LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Sharksucker</A></LI><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Slender remora</A> </LI><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Spearfish remora</A></LI><LI><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Whitefin sharksucker</A></LI><LI><IMG height=80 alt="The ');
writeln('top of a remoras head" src="the Suckerfish_files/remora6.gif" width=59></LI></UL></LI><LI id=last><DIV><A ');
writeln('href="http://www.htmldog.com/articles/suckerfish/example/">Links</A></DIV><UL><LI><A ');
writeln('href="http://www.itis.usda.gov/servlet/SingleRpt/SingleRpt?amp;search_topic=TSN&amp;search_value=168567">Remoras at ');
writeln('ITIS</A></LI><LI><A href="http://animaldiversity.ummz.umich.edu/accounts/remora/r._remora.html">Remora remora at ');
writeln('ADW</A></LI> <LI><A href="http://www.oceanlight.com/html/remora_sp.html">Phillip Colla photographs</A></LI><LI><IMG ');
writeln('height=35 alt=Remora src="the Suckerfish_files/remora3.gif" width=100></LI> <LI><A ');
writeln('href="http://www.amonline.net.au/fishes/fishfacts/fish/enaucrates.htm">Slender suckerfish at Australian Museum ');
writeln('Online</A></LI><LI><A href="http://www.colzoo.org/animalareas/shores/remora.html">Remora at Columbus ');
writeln('Zoo</A></LI></UL></LI></UL><HR>');}taken directly from the example.

mwinter
03-27-2005, 12:05 PM
The only idea that comes to mind is to write your menu as a document.write script and put it in the body of each page.The whole point of a mark-up based menu is to make it accessible, even if the script cannot be executed properly. To reintroduce a script dependency means you may as well use an inaccessible menu like HVMenu (or many other similar types).

The correct way would be to use server-side includes. That may, or may not, be supported by your host. An alternative would be to use a template- or macro-based editing tool. Whilst this would place the menu mark-up in every file, changes to the menu structure could take place without a lot of editing.

By the way, even if you do use document.write, you should only use one call. It is far more efficient to create an array of lines, join them, then write the resulting string:


document.write([
'...',
'...',
'...'
].join(''));Mike

jscheuer1
03-27-2005, 04:22 PM
The whole point of a mark-up based menu is to make it accessible, even if the script cannot be executed properly.I thought about that but, the sad truth is that as wonderful as this menu is, even in its original form, it is inaccessible if the user has no JavaScript capability. So, I'm not sure what you mean.

amoelle
03-27-2005, 06:37 PM
Hi all,
thank you for valuable help and hints.

I managed to include the menu (and join the array)

Another problem showed up: Special characters like danish and irish letters ,, and doesn't show properly in the menu.
But I take it, that proper escaped characters will do the job.

Have a look in the sandbox http://www.movingcloud.rootsmusicagency.com/pages/sweetnyaa.htm

The graphics and the skin is not final, I'm merely working on the structure...

I'll look into the possibility of running serverside scripts (it is possible at www.surftown.dk), but I'll need to research further.

... but I didn't get the last comment ??
are you saying, that some browsers don't support JacaScript, or that people, who turn the JavaScript option off, won't see the menu ?

All the best
Anne

amoelle
03-27-2005, 06:38 PM
the sandbox is located at

http://www.movingcloud.rootsmusicagency.com/pages/sweetnyaa.htm

/Anne

amoelle
03-27-2005, 06:39 PM
"http://www.movingcloud.rootsmusicagency.com/pages/sweetnyaa.htm"

jscheuer1
03-27-2005, 07:44 PM
Don't worry, we got the link the first time, this editor just makes it look cut off. Looks good! Yes. Without JavaScript available and enabled to do the mouseOver drop downs, suckerfish is dead in the water. Go to the example page and turn off JavaScript. No drop downs. The only difference is that with the original, the main headings are still visible and you can have them link to a page from which the content of its drop down is available via conventional links. To maintain this functionality in your setup, you need to leave the main headings on your pages as regular HTML, the rest (markup for the drop downs) can still be external script for ease of portability. Also, for example, your page:

http://www.movingcloud.rootsmusicagency.com/index.htm

Should have on it conventional links for all the content in the drop down for the 'Band' header on the main page's menu. This is the way if you want the fullest possible accessibility with this menu.

An alternative is to provide a limited set of conventional links via the <noscript></noscript> tag. Or at least language advising the user that JavaScript must be enabled. Most folks are using JavaScript and don't even know it so, don't fret too much. However, it sometimes happens that a site attracts mostly people without JavaScript. If this is the case, JavaScript is a poor choice. Oddly enough I master two sites dedicated to three music festivals, one of which is a roots festival focusing on the music of the Americas. On those sites I use JavaScript enhanced menus that work fine without JavaScript enabled. They have no dropdowns though, and must be written on each individual page. This web authoring is tough work and there are few real shortcuts if your goal is maximum accessibility. Efficient markup repeated across numerous pages takes time. With a good editor though, many pages can be changed at once. I like Edit Pad Pro. There are many available.

mwinter
03-27-2005, 08:07 PM
I thought about that but, the sad truth is that as wonderful as this menu is, even in its original form, it is inaccessible if the user has no JavaScript capability.I'm afraid you're wrong. If you disable the style sheet for the Suckerfish demo, you'll see the menu as a list - exactly what it's marked-up to be. The system would be more accessible if the menu started as a plain list and was altered afterwards, but it is better than most as it is.

All the script does is apply a style to the menu items so that IE will show submenus when a parent becomes the target of a mouseover event. Decent user agents don't need this as they support the :hover pseudo-class on more elements than just a. In any case, it is the author's responsibility to make the top-level items usable links so that an IE user who isn't prepared to disable CSS support temporarily (and most IE users wouldn't know they'd have to, let alone how) can navigate to section overview pages or to a site map.


Another problem showed up: Special characters like danish and irish letters ,, and doesn't show properly in the menu.
But I take it, that proper escaped characters will do the job.Really? They seem to display fine. However, as a general rule it isn't appropriate to use SGML character entities (&#nnn; or &name;) in scripts as a script engine has no real concept of entities. Instead, they should be escaped.

For example, a acute has the and &aacute; entity references. 225 in hexadecimal is 0xe1, so it would be escaped as '\u00e1'. If you look at the entity references list (http://www.w3.org/TR/html4/sgml/entities.html) in the HTML specification (http://www.w3.org/TR/html4/), you'll see that the hexadecimal values are written in the comments as U+xxxx.


I'll look into the possibility of running serverside scripts [...]You don't need full-blown script support, just SSI (server-side includes). It literally just includes one file within another.


... but I didn't get the last comment ??
are you saying, that some browsers don't support JacaScript, or that people, who turn the JavaScript option off, won't see the menu ?Yes, to all of those questions. Client-side scripting (on the Web, at least) should always be considered unreliable and optional. It should never be used to provide critical functionality such as navigation unless you have a fool-proof alternative available. A well designed system will degrade properly to that alternative so you wouldn't need to duplicate any information.

The number of possible visitors which will have scripting disabled will vary according to your target audience, so it's pointless to quote numbers.

Mike

jscheuer1
03-27-2005, 08:31 PM
If you disable the style sheet for the Suckerfish demo, you'll see the menu as a listThat's a pretty big if. You do have me though on it's being at least minimally accessible without script. I was thrown off because the demo goes nowhere when those links are clicked. If I was committed to using this menu with the external files, I'd just use the header menu with a noscript tag to pick up most of the slack. In the OP's case, just six links.

Oh, and by the way, what would be the fastest route to using SSI's?

jscheuer1
03-27-2005, 09:45 PM
I was thinking about this and the best of both worlds (without SSI, which looks like at the very least like a learning curve and a negotiation with one's host) might be to use the JavaScript portion of Suckerfish as an external file as well as the css. Use a small script to write the link to the style sheet in the head of your document and include the markup portion 'as is' in the document. That way everyone gets the whole menu.

One other note:

All the script does is apply a style to the menu items so that IE will show submenus...It also works with FF1.0.2 and NS7.2.

mwinter
03-28-2005, 02:46 PM
If you disable the style sheet for the Suckerfish demo, you'll see the menu as a listThat's a pretty big if.Not necessarily. If done properly, non-screen devices will always show the list (menu-like navigation features should always be limited to the screen, and possibly projection, media types). Unfortunately, this wouldn't help screen readers which tend to use a GUI user agent and read out what is displayed. However, if the top-level links are usable, this isn't really a concern.


Oh, and by the way, what would be the fastest route to using SSI's?Errm, what do you mean by "fastest route"? If that's related to your comment about a learning curve - there isn't one. A simple "include one file in another" SSI command would look like


<!--#include virtual="/path/to/file.ext" -->placed in any file with (typically) an .shtml extension. You can do more with SSI, but that's probably the most common use. The Apache server manual (http://httpd.apache.org/docs-2.0/) provides an introduction to server-side includes (http://httpd.apache.org/docs-2.0/howto/ssi.html). You can skip the configuration portion as the host will have already done that.

Note that the links are to the Apache 2 documentation. Most servers will be running 1.x, but the content (in this case) is largely the same and certainly better presented.


One other note:


All the script does is apply a style to the menu items so that IE will show submenus...It also works with FF1.0.2 and NS7.2.I know. However, Opera and Gecko browsers (presumably Konqueror and Safari, too) don't need it. Their dynamic CSS support is far superior to that of IE and the drop down effect will still work with scripting disabled.

Mike