Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

if (keyword_contains "keyword")...

I want to have one template for all pages in my site. To do this I was hoping to have all components in the template, then use a construct similar to

if (keyword_contains "keyword")
<text/HTML to display when keyword is present>

For example, I want my site counter to only appear on the main index.html page.  So I was hoping to add a keyword "frontpage" to that article, then code the above.

I see that this isn't possible - that keywords are used with the foreach command.  However, I don't want this to be a loop statement, just an IF statement.



David Watts
Monday, January 13, 2003

The "if" only works to determine if a field is blank or not.  That's as far as it goes for now. You can't do an "if(keyword_contains ...).  You can certainly use keywords to choose articles for specific pages and a different script for each page.

Your best best may be to use folders to organize your articles.  Darren explains it here:

Apart from that, the folders are a big help in organizing because the CityDesk main window is a folder/file view.  So, if you are organizing by folder you can visually tell what's going on.  You'll still need different scripts to choose from different folders.

You can still use one template if that meets your needs.  The few templates the better for me.

Monday, January 13, 2003


Thanks for the speedy reply. I guess what I'm trying to do is to just have one template that all my files use:

index.html entry point (one file)
index file for each folder (multiple files)
articles in each folder (multiple)

What are the methods you use reduce the number of templates? 

David Watts
Monday, January 13, 2003

The best thing about CityDesk is that you can mess around with templates and scripts.  Get the articles in there and experirment until you get the best site you can with the best manageability you can.  Sometimes you might compromise your ideal site design a little to take advantage of CityDesk.

I get this site done with one template for the index file and one other template for all the other articles (270 so far).  But I could have used the index template for all the files.  I used to have several for this site but I've weeded them out.

One thing I do on the site is use Extra2 as the title for each article.  I use Extra1 as a subtitle if the article needs one.  So, for example there is a letters page: "Letters" is in Extra2 of all the letter articles and the title of each letter is in it's Extra1 field. (I started that because I needed to italicize ship names in article titles but I couldn't italicize in the Headline field.)  I use keywords too but just to make a site index that helps kepp the author and me from going crazy.

There is a picture of the site in CityDesk at the bottom of this page:

I'm not sure that I'm helping.  Most of the forum folks are more clever than me.

Monday, January 13, 2003

*  Recent Topics

*  Fog Creek Home