Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Using variables in loop statement...

Hi all...

My website has many folders and many articles in each folders. I'm using the first article of each folders to make a list of all my folder in a menu on the side of my pages.
Like this:

{$ foreach x in (keyword_contains "(main)") $}
<A href="{$x.link$}">{$x.headline$}</A><br>
{$ next $}

(Each first article has a (main) keyword)

When a user click on a folder, I liked to make a second list of all the acticle in that folder. Unfortunatly, CD doesn't allow putting CD script into a loop statement.

Something like this.

{$ foreach x in (keyword_contains "{$.filename$}") $}
<A href="{$x.link$}">{$x.headline$}</A><br>
{$ next $}

(Note the position of "{$.filename$}" )

Since the folder that I'm in has the same name as the first article, this should list all the articles of that folder. But like I said, this doesn't work. Any Idea?

Something even better would be to have a menu like this:

{$ foreach x in (keyword_contains "(main)") $}
<b>{$x.headline$}</b><br>
{$ foreach y in (keyword_contains "{$x.filename$}") $}
- <A href="{$y.link$}">{$y.headline$}</A><br>
{$ next $}
{$ next $}

That should create a menu like:

Folder A
- Article A1
- Article A2
- Article A3
Folder B
- Article B1
- Article B2
- Article B2
Folder C
- Article C1
- Article C2

Is it possible to make such menu?

Also, it would be nice to have a "IF" statement. I can see so many use for it.

Thanks

dan...

Daniel Quimper
Sunday, January 06, 2002

Does this help:

http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=1280&ixReplies=3

I think you can do it.

TK
Sunday, January 06, 2002

I'd like to second the request for the ability to use the attributes of the current object as selection criteria.

I would like to implement next and previous links using

{$ foreach 1 x (before .fileddate) $}

or similar in a template.  Article to article linking is the one thing stopping me using City Desk for my site.

Nick Delany
Monday, January 07, 2002

Thanks TK,

I seen that example. It almost produce what I want.

In:

Folder
- Article 1
- Article 2

I would like that "Folder" is not a link. And the artcles are link to the acticles. But I guess it's impossible.

Or that I can click on a folder to see its content.

Folder A
Folder B
- Article 1
- Article 2
Folder C
Folder D

The only way I could do that is to have a special template for each folder. I guess I'll wait for CD version 2 to simplify my website.

Joel, could we have a list of new features that are planed for version 2?

dan...

Daniel Quimper
Monday, January 07, 2002

*  Recent Topics

*  Fog Creek Home