Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

No ability to reuse loops?

Based on my experience, and the forums here I just want to confirm that as of CD 2.0 you can't reuse loop code.  Meaning you can't have a foreach statement with any condition using a field or variable (e.g. foreach x in (filename "{$.field$").  Even trying to start and end a loop with variables, and putting the condition in the body of an article does not work.

So the next best thing would be at least putting the "body" code of the loop into a variable and then just having to specify individual foreach and next statements with your variable inbetween.  but this does not work either as the variables must be interpreted first and not inline with the loop, so whatever variable you set for loop will give an error.

This leaves one to have to make loops and the code for each section they want, even if the loops is doing the exact same thing, just in different sections of the site.  Are there other methods?

Russ Hollmann
Wednesday, August 20, 2003

*  Recent Topics

*  Fog Creek Home