Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Where am I? Navigation

Just happened upon this stuff and it looks interesting :-)

Question: Can IF be used to compare values?

What I'm really wanting is to highlight the current article in the navigation list.

{$foreach x in (folder "articles")$}

IF (x.isTheActivePage)
You are HERE ---> {$x.headline$}
{$x.headline$} -- {$$}


Tim Colson
Tuesday, May 14, 2002

This is a much requested but, so far, unavailable feature.

Tuesday, May 14, 2002

I have solved this using foreach and javascript. For the javascript I've created an empty template with the .js extension.

// ***********begin javascript article********
var arMenu=new Array (
{$foreach a in (and (filename "index") (folder "")) $}
{$foreach a in (and (filename "index") (not (folder ""))) $}
// arMenu[][2] contains all paths\index.html with known header names

var pijl=' <IMG src="/mnu/pijl.gif"> ';
var topMenu="";
function FindMenu(path)
  for (var index=0;index<arMenu.length;index+=2)
    cmp= arMenu[index].substring(0,arMenu[index].lastIndexOf("/"));
    if (path == cmp)

      if (topMenu != "") topMenu=topMenu+pijl;
      topMenu=topMenu + '<A href="'+arMenu[index]+'">'+arMenu[index+1]+"</A>";
      return 1;
  if ((path==arMenu[arMenu.length-2]) && (path.indexOf("index.")<0) )
      topMenu=topMenu + pijl + '<A href="'+ arMenu[arMenu.length-2]+'">'+arMenu[arMenu.length-1]+"</A>";
      return 1;
  return 0;

// find this file
    var menu="";
    var myString=unescape(location.pathname);
    myString=myString.replace(/\\/gi,"/");  //make it work for previews

    var lastindex=0;
    var index = 0;
    var einde=0;
    var startindex=lastindex+1;
    do {
      index = myString.indexOf("/", lastindex);   
      if (index<0) FindMenu(myString.substring(startindex-1,1000));
        if (!FindMenu(myString.substring(startindex-1, index)))
    } while (index != -1);

// ***********end javascript article********

in the template

I write a menu like
_home _product _page
(where _x is a hyperlink to a page 'x')

The IMG tag is a '>' symbol; unfortunately I can't use the FOG reference in here since Citydesk always generates relative links which will not work since the menu is used at different locations than the location of the script.

The script assumes that there is an index article in each folder.

I hope this helps you.

Adriaan van den Brand
Wednesday, May 15, 2002

I've posted it at tk's website as a cty-file

Adriaan van den Brand
Monday, May 27, 2002

*  Recent Topics

*  Fog Creek Home