Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

detecting no articles in foreach stmt

Each committee runs its own meetings and events.

If there is no meeting or events, the foreach stmt returns nothing, and have a table with no text in it.

I don't want a blank table, I want the text "no events are scheduled" to show up.

The foreach stmt:

{$foreach article in (and  (after today)(keywordContains "event")(keywordContains "committee_name")) $}
{$ article.headline $}
{$next$}

The pseudo code is...

{$foreach article in (and  (after today)(keywordContains "event")(keywordContains "committee_name")) $}

if no articles are found, display "no events are scheduled"
else {$ article.headline $}

{$next$}


One solution is to create an article with the event name "no events are scheduled". I'd prefer an script solution, though.

Thank you :-)
-Bob

Bob Bloom
Saturday, July 05, 2003

See "fancy loops" in the scripting section of help file for CD v2

Joel Goldstick
Saturday, July 05, 2003

Joel,

Thanks for your reply. I didn't know that there was an {$ else $} stmt in the foreach loop. Works perfectly!

Bob Bloom
Saturday, July 05, 2003

*  Recent Topics

*  Fog Creek Home