Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Use (folder) variables in a loop

I would like to be able (apart from if-then-else constructions ofcourse! :-) to use something like this....

{$ foreach x in (folder "{$this.foldername$}")$}

or using the {$.extra1$} value for example:

{$ foreach x in (folder "{$.extra1$}")$}

It seems quite simple...

Is there any way of doing this (using the 'current folder/file')?

Thanx

dave-it
Wednesday, February 26, 2003

Whoops This is about the tenth time this is asked... sorry...

(I did read a lot of forum posts before posting this question, rellY!)

So it cannot be done huh??

dave-it
Wednesday, February 26, 2003

You might want to take a look at these threads, the last one shows how to implement breadcrumbs in javascript using foreach...

http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=5469&ixReplies=2
http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=3720&ixReplies=1

David Burch
Wednesday, February 26, 2003

Wow! it works fine, but it just seems so complicated for such a  'simple' task.

If just... ;-)

Why can I use CityScript in a 'keyword_contains' thing, but not in a 'folder ' thing??

This works:

...blah blah... keyword_contains "{$.extra1$}"

But this doesnt:

...blah blah... folder "{$.extra1$}"

Why is that?

I have also tried to use slashed ("/" and "\") or dots (".") in the folder syntax, like ; folder "./"
doesn't work....

I could fix it using :

{$ foreach x in (keyword_contains "{$.extra1$}")$}

and then fill in a keyword and an exact {$.extra1$} variable in every file, seems like a lot of extra work (which is easily forgotten!)

Anyway, thanx for your help! ;-)

dave-it
Wednesday, February 26, 2003

I'm not sure you can use a variable in cityscript as you suggest...

the folder thing is probably an oversight. the next version is sure to have it as it's probably the #1 asked for feature.

www.marktaw.com
Thursday, February 27, 2003

Here's another example of using a combination of JavaScript and a CityDesk script foreach to build a SiteMap.  It could be modified to obtain folder information:
http://www.citydesktemplates.com/Templates/SiteMap.html

David Burch
Thursday, February 27, 2003

*  Recent Topics

*  Fog Creek Home