webCOMAND

#FOREACH

Processes and outputs cTemplate between #FOREACH() and #ENDFOREACH for each item in a collection, making the item available as a named variable.

Prototype

#FOREACH($collection as $item) ... #ENDFOREACH
#FOREACH($collection as $key:$value) ... #ENDFOREACH

Parameters

  • collection - A collection variable to iterate over it's items.
  • item - Variable to assign to the item in the collection that corresponds to the current iteration.

Example

#/ List events from a Publication List with the Identifier "Events"
#FOREACH($Events as $Event)
${Event.Date} - ${Event.Description}
#ENDFOREACH

Related

#LIST, #FOR, #CQL, #CPATH, #SQL