This page is no longer updated

We've left it here for reference. Find Out More.

PlanetHITOP

Basic Hitop.

6. More Basic @NAV

The navigation we've looked at so far is very simple. In the real (or should that be virtual?) world, life is never that easy.

Let's build upon our radio site. So far we have pages for four radio stations and a contents page. What if we want to add a new section about pirate radio? Well that's very easy - just add an extra entry onto the @NAV data - bung it in, run Make on your templates and there it is. Easy eh?

However, pirate radio is such a big topic, we want to have three pages to the pirate radio section - for Radio London, Radio Caroline and Radio Luxemburg. We could just add three entries to the @NAV data in the way we know how, but this is not a very elegant solution.

A much better way is to create a new subsection or 'Level' of the navigation system, which can be done as follows:

<@NAV DATA="Contents=contents.html,Pirate Radio=(Radio London=radiolondon.html,Radio Caroline=radiocaroline.html,Radio Luxemburg=radioluxemburg.html),BBC Radio One=radio1.html,BBC Radio 5 Live=radio5live.html,BBC GLR=bbcglr.html,xfm=xfm.html" FORMAT="FOLDED">

The important thing to look at is this piece of the @NAV data:

Pirate Radio=(Radio London=radiolondon.html,Radio Caroline=radiocaroline.html,Radio Luxemburg=radioluxemburg.html)

What this says is create a nav entry called Pirate Radio, and have three sub-pages of that section.

So what output do we get? Perhaps the best way to see is to view a page with all the nav types on - click here to see our ammended radio example in a new window, and have a play.

What you'll see is that on an OPEN nav, the three Pirate Radio subsections are always displayed no matter what. In a FOLDED nav, the three Pirate Radio sections will only be displayed once you've clicked on the Pirate Radio Link - they appear below Pirate Radio, indented. In an OPEN nav, they always appear, intended, below the Pirate Radio entry, and on a FLAT nav, they appear below on a new line.

External Nav Files

Looking at the @NAV statement above, it should be pretty clear that, for any site, things could get very complex. Thankfully there is a much better way to do your navigation.

The information @NAV needs does not have to be specified by using the DATA parameter. Instead we can create an external nav file. An external nav file for the above would look like this:

Contents=contents.html
Pirate Radio=
 Radio London=radiolondon.html
 Radio Caroline=radiocaroline.html
 Radio Luxemburg=radioluxemburg.html
BBC Radio One=radio1.html
BBC Radio 5 Live=radio5live.html
BBC GLR=bbcglr.html
xfm=xfm.html

As you can see, the file is laid out in a similar style to the way that an OPEN nav is displayed on the screen, using the sitename=siteurl.html syntax used in the DATA parameter. Each entry is on it's own line. If you want an to create a new level, the name of the level does not have anything after the equals sign (see 'Pirate Radio' above) and the entries in that level are all indented by 1 space. Obviously you can have nested levels - just indent by one extra space for each level.

This file can then be saved with any name, as long as it is saved in the root directory - NAV files cannot be called from sub-directories. We'll call ours radio.nav - I use the .nav extension to show that the file holds nav data.

radio.nav can now be called from within your template using the following command:

<@NAV SRC="radio.nav">

Of course, any FORMAT parameters you desire can still be passed through in the same way as before.

Your external .nav file should also be added to the templates section of your Makefile, so that your template line should look like this:

TEMPLATES = template.hitop radio.nav

Doing this will ensure that every time you run a make, the nav file will be checked to see if it has changed, as well as the templates.

Common Questions About @NAV

I am being told there is an error in my nav file. It looks right, so what is the problem?
Usually this is caused by the presence of an extra, blank line at the end of the .nav file. Just go to the bottom of the file, and delete any extra lines after the last entry. Also check that there are no spaces before and after the = sign.
What happens if I use DATA and SRC in my @NAV command?
Why you would want to do this I really don't know, so if you do, you deserve everything you get! Sadly you don't get that much... SRC takes priority over DATA every time. Now stop asking strange questions you twisted person.
Can I customise my @NAV bar more?
Oh yes. We'll learn more in a later chapter. @NAV is very customisable...

@NAV is also very easy to use - no matter what you want to do with it. Have a play around with what you know now and see for yourself.

You can download the example files for this section here


<back | top^ | next>

Planet Bods NetworkSites in the network