Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Smart Navigation Bar

Simple Question:

I'd like to create a left-hand Navigation Bar on the fly.

I've got it working, no problem, HOWEVER, I would like to remove any self-referential links.

So for example, if my sites navigation bar looks like this:

- Home Page
- Products
- Contact Us
- About Us

And the user is currently viewing the "Products" page, I wan't the navigation to look like this:

- Home Page [link]
- Products
- Contact Us [link]
- About Us [link]


Here is the code I came up with, stored in a variable called NavBar:


{$foreach x in (and(all)(keyword_contains "menu"))SortAscendBy .keywords$}

<A href="{$x.link$}"><font color="#FFFFFF">{$x.extra1$}</FONT></A><br><br>

{$ next $}

(note, i use the "extra1" field and store: "1menu, 2menu, 3menu" so it sorts just the way I want it to)



If I could only do a simple IF...ELSE then I would be good to go!:

{$foreach x in (and(all)(keyword_contains "menu"))SortAscendBy .keywords$}

{$ if {$.extra1$} = {$x.extra1$} $}
<font color="gray">{$x.extra1$}</FONT></A><br><br>
{$else$}
<A href="{$x.link$}"><font color="#FFFFFF">{$x.extra1$}</FONT></A><br><br>
{$endif$}

{$ next $}


Please help.  I assume this is a common problem.  I really can't understand why a simple IF...ELSE isn't supported.  Why limit to simply if BLANK, NONBLANK.  Why can't we simply check other conditions: IF [this] = [that]

anthropocentric
Sunday, February 09, 2003

Welcome to the club.... this is long requested functionality.

I use javascript and/or php to do it. Much more complex, but it works. By the way, it requires a little more effort than you may think, as a 'main menu' may only show categories, but multiple articles can reside in one folder. So there you'd need some string parsing functions.

Adriaan van den Brand
Sunday, February 09, 2003

Can you give me an example of a way to get this to work?  I don't care about the SUB pages, just the main pages.

anthropocentric
Thursday, February 13, 2003

The easy solution of course is NOT to remove the self referential link. I think they disturb/confuse the webmaster more than they disturb/confuse visitors ... but then again, if there were an easy way to avoid them ...

Jorgen Brenting
Thursday, February 13, 2003

Well, i designed my site so that the obvious difference between the current page and the other page would serve to give the user a sense of location.  So, instead of writing "Articles" on the top of my articles page, the navigation on the left would look like this (Essentially telling the user the same thing):

Home [link]
another [link]
someother [link]
Articles (bold, different color)
About Me [link]

If I can't get this to work, I really have to change my whole design...

anthropocentric
Thursday, February 13, 2003

You may not like this but you could have identical templates for each group of pages - exept for the left navigation bar. I had this until I realised that it only was important to ME and that it was much more easy just to include it all in one template showing all links. See an example (in Danish) here: http://www.baskerville.dk/Engelsk/StartsideEngelsk.html

Jorgen Brenting
Thursday, February 13, 2003

See "Site made with CD".

I've worked around a number of CD's glaring shortcomings.

Chad Z. Hower
Saturday, March 01, 2003

*  Recent Topics

*  Fog Creek Home