Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Complement for foreach loop?

Say an index page has the following code:

{$foreach 5 x in (all) SortDescendBy .fileddate$}

Is there a perfect complement (listing exactly all other articles, but still in descended order) for the archive page?

I know it's a deceptively complicated question, and may even require a new foreach keyword.  But it'd be very handy to have.

Please don't reply with approximations that wouldn't work in every conceivable realistic situation.  I've got one of those.

David Blume
Saturday, June 15, 2002

No, there isn't, and that's a feature request IMO.

However, in your specific case I'd argue that an archive page should contain everything, not just "the stuff that's not on the front page". That's just me. :)

Brad Wilson
Saturday, June 15, 2002

Well, it's not just Brad who thinks it's better to have it all in the archive page. I favor that too - it's easier for the reader that way.

Jorgen Brenting
Saturday, June 15, 2002

We had this discussion before on the forum.  Most folks agreed on the archive thing. Most surfers would expect an archive to list everything.

But a common theme is that folks would like to do a just a little more arithmatic and have slightly more powerful "if" conditions in their CityScripts.  Who knows what kind of tricks you could come up with?

Saturday, June 15, 2002

A good application of david's idea would be to list the 5 latest articles with the title and the teaser, and list the others with only the title, on the same archive page, or on two different ones, up to the site designer's choice.

Generally, It would be fine if we could "break the loops". Examples of applications  :

- on the home page, list the five first articles (according to the chosen sorting criteria) with headline plus teaser, the five following with headline only.

-  display lists in multiple columns in a two or three cols table.

(but imho it's not a "first level priority" feature request)

Vincent Benard
Sunday, June 16, 2002

a more complete 'if' statement and a loop counter would be ideal. Keep it simple and powerful....
{$foreach x in (all) SortDescendBy .fileddate $}
  {$if x.count <5 $}

(but then, please make ALL fields and conditions available in both foreach and if)

Adriaan van den Brand
Tuesday, June 18, 2002

Everyone around here seems to have forgotten that they're replacing CityScript for some more powerful, already existing scripting language. I, not being much of a scripter, forget what it is... VBscript maybe?

CityScript will still exist and work, but this other language should allow for much more complex stuff. We just have to sit patiently and wait. Or not so patiently.

Thursday, June 20, 2002

*  Recent Topics

*  Fog Creek Home