Welcome Guest!

If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:

  • Receive Fast Advice
  • Learn Programming Languages
  • Get Professional Website Reviews
  • Quick Troubleshooting Assistance

> Automated Navigation For Content-heavy Websites

This is a discussion on Automated Navigation For Content-heavy Websites, within the Squeeze Bar section. This forum and the thread "Automated Navigation For Content-heavy Websites" are both part of the The Squeeze Center category.

 
Reply to this topicStart new topic
> Automated Navigation For Content-heavy Websites, possible tutorial
MikeHopley
post May 6 2008, 08:10 AM
Post #1


Squeeze Machine
Group Icon

Posts: 677
Joined: 15-February 08
From: UK


The problem

As some of you may know, I write multi-page articles on my badminton website. For example: a badminton grips guide.

Take a look at the table of contents for that article. Now imagine coding all the "next page" and "previous page" links. If you've ever published this kind of structured content before, you can appreciate how tedious the coding is. As well as the markup (<li><a>...), you must specify an HREF and link text or TITLE.

I also offer three different skill levels (a CSS filter, essentially), and some pages are absent in lower skill levels. That means I have to code different next/previous links for different skill levels.

Finally, I also use <link rel="..."> to provide an extra layer of navigation that is incorporated directly into the browser (see the Firefox link widgets addon). I admit this is currently obscure, but it's a superb accessibility aid. Potentially it's useful to anyone (not just disabled people), because it allows you to describe the structure of the document. I've written about this before.

But imagine coding all those links for every page of every article. Not just next/previous, but also sections, subsections, first/last, and so on.

The volume of coding is awful. And naturally, when you're coding so many links, you're likely to make errors.


The solution

All the necessary information is encapsulated in the table of contents. Given that I must write a TOC anyway, why not use it to generate all my nav? I wrote a PHP script that does exactly that.

The TOC can be specified in a minimalist form. For example, here's my TOC file from the grips guide:

CODE
<?php
     $level = 3;
     $tocArray =
    
         "|Introduction|Badminton grips guide
         ||grip-principles|Grip principles|Badminton grip principles
         ||racket-bevels|Badminton racket bevels
         ||grips/|Fundamental badminton grips
             ||+||basic-grip|Basic grip|The basic badminton grip
             ||panhandle-grip|Panhandle grip|Badminton panhandle grip
             ||thumb-grip|Thumb grip|Badminton thumb grip
             ||bevel-grip|Bevel grip|Badminton bevel grip*IA
         ||-||changing-grip|Changing grip|Changing between badminton grips
         ||grip-adjustments/|Adjusting your grip|Adjusting your badminton grip*IA
             ||+||grip-length|Grip length|Badminton grip length
             ||late-forehand-grip-adjustment|Late forehand|Late forehand grip adjustment
             ||late-backhand-grip-adjustment|Late backhand|Late backhand grip adjustment
             ||smash-grip-adjustment|Smash|Smash grip adjustment*A
         ||-||which-grip/|Which badminton grip?|Which badminton grip for each shot?*IA
             ||+||serve|Serving|Which badminton grip for serving?
             ||serve-return|Returning serve|Which badminton grip for returning serve?
             ||net-shot|Net shots|Which badminton grip for net shots?
             ||net-kill|Net kills|Which badminton grip for net kills?
             ||drive-push|Drives and pushes|Which badminton grip for drives and pushes?
             ||lift|Lifts|Which badminton grip for lifts?
             ||smash-defence|Smash defence|Which badminton grip for smash defence?
             ||clear-smash-drop|Clears, smashes, and drops|Which grip for clears, smashes, and drops?
         ||-||background/|Background information
             ||+||old-grips|What about the old grips?|What happened to the old badminton grips?
             ||grip-size|Grip size|Badminton grip size
             ||marking-the-racket-handle|Marking the racket handle|Marking the badminton racket handle
             ||alternative-views|Alternative views|Alternative views on badminton grips*A
             ||mechanics-of-grip-length|Mechanics of grip length*A
         ||-
    
     ";?>


This needs some explanation. I use "||" to separate the list items. "+" denotes the beginning of a nested list; "-" denotes the end.

Each entry has up to four parts: a file location, a TOC title, a full title, and a skill token (*A is the token for "advanced"). These parts are separated by "|" (or by "*" for skill tokens).

All the page navigation, including <link rel="...">, is then generated from this file. It also generates the current page title and <h1>.

Generating the nav has several advantages:
  • Much faster to code
  • Much faster to reorganise an article (just move the files around, and edit the TOC)
  • Much less chance of making an error (and errors are much easier to find/correct)

A question for you

Is this useful for you?

I could be persuaded to write a tutorial on this, but I'd rather not bother unless people might actually find it interesting or useful.

It's certainly useful for me; but I may be unusual in publishing structured documents with lots of pages.


This post has been edited by MikeHopley: May 6 2008, 08:15 AM
Go to the top of the page
 
+Quote Post
Justify
post May 6 2008, 09:15 AM
Post #2


Squeezing
***

Posts: 96
Joined: 14-February 08


Im interested. Alot of things like wordpress, magento etc use a simliar principle. Would be good to see some reverse engineering for it.
Go to the top of the page
 
+Quote Post
MikeHopley
post May 6 2008, 09:47 AM
Post #3


Squeeze Machine
Group Icon

Posts: 677
Joined: 15-February 08
From: UK


QUOTE (Justify @ May 6 2008, 03:15 PM) *
Im interested. Alot of things like wordpress, magento etc use a simliar principle. Would be good to see some reverse engineering for it.


I've never actually used a blog engine such as Wordpress (because I've never had a blog, perhaps...).

I wonder to what extent my auto-nav is built into something like Wordpress?
Go to the top of the page
 
+Quote Post
Jason
post May 6 2008, 10:12 AM
Post #4


Master of the Universe
Group Icon

Posts: 1,298
Joined: 15-February 08
From: London, England


I am doing something very similar to what you are doing. The difference between mine and yours is that my navigation is stored in a database. (The query is cached obviously).

I would be interested to see how you output your navigation and how it differs from my approach.


--------------------
Go to the top of the page
 
+Quote Post
welshstew
post May 6 2008, 10:55 AM
Post #5


Squeezing
***

Posts: 82
Joined: 14-February 08
From: inside the outside


I would be very interested Mike, as I am building something very similar in asp. - looping functions and navigation overrides are starting to make my head hurt!


--------------------
Go to the top of the page
 
+Quote Post
rewake
post May 6 2008, 11:08 AM
Post #6


Rapid Squeezer
Group Icon

Posts: 239
Joined: 14-February 08
From: NY, USA


Hey guys,

I think this would be a great topic for a tutorial... it's an interesting challenge each time. The breadcrumb navigation on the Raineri Jewelers website is dynamically generated based on it's assigned category. I store the category paths as normal paths...

/jewelry/rings/diamond-rings (for instance)

and then explode() the values to show the sections...

Jewelry > Rings > Diamond Rings

Each of the parent categories have category names assigned to them which allow me to display a different category name than the path itself.

Rich


--------------------
QUOTE
if ($name=='will') echo '/(bb|[^b]{2})/';

Raineri Jewelers | MySpace | Facebook | deviantART
Go to the top of the page
 
+Quote Post
Justify
post May 6 2008, 01:28 PM
Post #7


Squeezing
***

Posts: 96
Joined: 14-February 08


yea incorporating what rich said sounds good to me 8-)

need to get some of the principles of it in my head properly before i start thinking about it. The database thing is what magento uses. It gets categorys and prints them as a list.
Go to the top of the page
 
+Quote Post
MikeHopley
post May 8 2008, 08:13 AM
Post #8


Squeeze Machine
Group Icon

Posts: 677
Joined: 15-February 08
From: UK


Since there's some interest in this, I'll try to put something together when I have time.

QUOTE
The breadcrumb navigation on the Raineri Jewelers website is dynamically generated based on it's assigned category. I store the category paths as normal paths...


Yes, I do much the same thing with breadcrumbs. That script alone has saved me an ungodly amount of coding.

Lush website, by the way. smile.gif
Go to the top of the page
 
+Quote Post
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   7 Blake121 349 15th February 2008 - 02:07 PM
Last post by: karinne
No New Posts   3 jamesicus 295 1st April 2008 - 10:42 AM
Last post by: karinne
No New Posts   0 Daniel 290 18th February 2008 - 08:51 AM
Last post by: Daniel
No new   17 902 676 22nd February 2008 - 11:11 AM
Last post by: Stuart
No new   15 902 679 25th February 2008 - 04:06 AM
Last post by: JasonStanley