Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you generate website navigation?

I am interested in how other people handle website navigation. Not the styling or usability part, but the generation part. Most websites have some kind of “navigation tree” that is displayed in form of one or more menu levels – in what form do you save and process this tree? The simplest solution is a static menu template, something like this:

<ul id="menu">
   <li><a href="…">One</a></li>
   <li><a href="…">Two</a></li>
   <li><a href="…">Three</a></li>
</ul>

But this is not very flexible. You can’t simply mark the current page in the menu and there’s no simple way of showing or hiding a part of the menu tree depending on the current page. (Or is it?)

I came up with a navigation tree, something like this:

    - title: Fruits
      nodes:
        - title: Apples
        - title: Oranges
        - title: Bananas
    - title: Music and Stuff
      url: music
      nodes:
        - title: Classical
        - title: Jazz

This tree gets loaded by a special Navigation class that can serve parts of the navigation depending on the current request path. This seems to work a bit better, but still I am very curious about other people’s solutions.

like image 854
zoul Avatar asked Dec 07 '09 13:12

zoul


3 Answers

MySQL has an article entitled "Managing Hierarchical Data in MySQL" which I have previously found to be quite invaluable. It discusses two common techniques to storing dynamic navigation and their limitations.

like image 136
Corey Ballou Avatar answered Sep 21 '22 16:09

Corey Ballou


If ASP.NET is your flavor, Sitemaps work great

like image 31
Ta01 Avatar answered Sep 20 '22 16:09

Ta01


You might find one of my modules useful: CatalystX::Menu::Suckerfish

The menu structure is generated from method attributes. It lacks a way to alter the state of the current page's menu entry, but that shouldn't be difficult to add.

The method attributes are arbitrary strings MenuPath and MenuTitle which specify a slash-delimited path for the menu option in the tree and a string that is used as the menu option label and an html title attribute, where applicable.

like image 36
converter42 Avatar answered Sep 19 '22 16:09

converter42