Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Automatic breadcrumbs for 2 menu levels

I like to create breadcrumbs but they should be created automatically. In the websites I create with CityDesk, I like to use folders which contain files on the same subject (for example "news") and I put an index file in each folder. It generates a menu for all articles in this folder and presents a welcome page for the folder subject.

For a website which works with two menu levels, for example a main menu and a submenu for each main menu item, I created the following script:

<a href="PTMFOG0000000013">Home</a>
{$ foreach 1 x in (and thisFolder (fileName "index") not(keywordContains "HOME")) $} &gt; <a href="{$$}">{$x.headline$}</a>{$ next $}
{$ foreach 1 x in (and thisArticle (not(filename "index"))) $} &gt; {$ x.headline $}{$ next $}

It always shows "Home" with a hyperlink to the index file of the website, which contains the keyword "HOME".

Secondly, it shows " > " and the headline of the index file in the current folder (if this is not the main index file with "HOME" in it's keywords)

Last, it shows " > " and the headline of the current file (which can again be a index file)

In the example website the following breadcrumbs can be generated automatically:

Home > Sports
Home > Sports > Nonfootball
Home > Sports > Football
Home > News
Home > News > International
Home > News > Local
(provided that the headlines for the index files are named "Home", "Sports", "Nonfootball", "Football", "News", "International", "Local", etcetera)

Kind regards,
Johan Willems
Limit ICT Professionals (under construction)

Johan Willems
Monday, September 22, 2003

That's great, thanks Johan. I've implemented your idea on my site,


David Watts
Tuesday, September 23, 2003

*  Recent Topics

*  Fog Creek Home