Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Easy to use "nav bar" options?

I'm re-writing the nav bar on my pages, and I'm getting the feeling I'm doing it the hard way - a variable with some HTML in it.

A better solution would be to have an article in some folder (say /site_stuff/navbar) so that I have the easy to use editor and link re-writing.

So has anyone tried including the content from one article as "include text" in their templates? Is this possible?

Maury Markowitz
Friday, February 08, 2002

{$ foreach 1 x in (filename "article") $}
{$ x.body $}
{$ next $}

-> same as an include.

Joel Spolsky
Friday, February 08, 2002

I'm curious as to what happens if you have two articles in two different folders with the same name. I was able to cut & paste articles from folder x to folder y without any change in the file name.

Mark W
Friday, February 08, 2002

By default if you had the "1 x" clause you'd get the article you created first - then again, you can always add a sortby to the loop and get whichever article you wanted.

Michael H. Pryor
Friday, February 08, 2002

err. Wouldn't {$foreach 1 x...$} give you the LATESt article only?

Mark W
Friday, February 08, 2002

My less-than-intuitive method has been to put navbars in global variables. This is somewhat annoying because global variables aren't designed to handle HTML.

Now I can reference the navbar in the code {$.navbar_home$}.

Then if I need to do this in a template and have multiple navbars, I make it {$.extra1$} in the template. Then in the {$.extra1$} field I put {$.navbar_home$}. This allows you to have 1 template and multiple navbars.

Less than intuitive, like I said, but it works. The ideal way would be to have a set of global variables that populate a dropdown menu somewhere in the article.

Mark W
Friday, February 08, 2002

*  Recent Topics

*  Fog Creek Home