Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Can (folder "XXX") be variable?

I have a specific site structure in mind, and cannot seem to find a way for CD to deliver this elegantly. My site is a simple hierarchy with articles in folders A, B, and C. On the front page I want to put the names of the folders in the left hand side navigation bar. To do this I create a document for each folder in the folder Articles and use the {$ foreach x in (folder "Articles")$} loop in the template for the front page. In the document for folder A (in folder Articles), I want to have a left hand side navigation bar exactly the same as for the front page, so this time I use the loop {$foreach x in (folder "A")$} loop in the template for documents in folder A. And so on for folder B and C. What I would like to do is to have one template for the entire site and use a loop like {$foreach x in (folder {$x.extra1$} ) $}. Can this be done? Or can my effect be achieved in some other way?
Here is the structure:
- index.html, template Index
- folder Articles
- - document A, template A
- - document B, template B
- folder A
- - document A1, template A
- - document A2, template A etc.

Richard B
Wednesday, October 8, 2003

The folder name can't be a variable (yet!) but you can achieve what you want using a workaround:

Create an article named "index" in the main folder, and all subfolders.  Put the subcategory name into the headline field of each "index" article.

Then have your script loop over (fileName "index") to find and list all main- and subcategories in form of a link to their appropriate index article.

Then loop over (thisFolder)  to find and list all other articles at the same hierachy level as the current "index" article.

With the (ab)use of one of the "extra" fields to indicate the nesting level you'll be able to distinguish optically (say indent, different font size) between main and subfolders...

Thursday, October 9, 2003

*  Recent Topics

*  Fog Creek Home