Logic Tags
Tag foreach


This tag allows you to loop over data collections stored in memory as XPArrayLists. The data collection should not be modified while looping to avoid unpredictable side effects. The index value in a foreach loop is key+index (i.e. $varindex).

Example:
<pt:logic.foreach pt:data="testcollection" pt:var="co">
<pt:core.html pt:tag="a" href="$co.url">
<pt:logic.value pt:value="$co.name"/>
</pt:core.html>
<pt:logic.separator><br>-----<br></pt:logic.separator>
</pt:logic.foreach>


Tag Information
Tag Nameforeach
Related Child Tag(s)separator

Attributes
NameTypeRequiredDefault ValueDescription
datastringtruenullThe key used to retrieve the XPArrayList data collection as a shared variable from Tag, PortletRequest, or Session scope memory.
varstringfalseforeachvarThe key used to store the current IDataObject in Tag scope memory as an editable shared variable. This tag will restore the original value of this variable after the tag is finished processing, meaning that multiple foreach loops can share the same variable name, although it is considered a best practice to use unique names for the variable attribute for each foreach tag. If this variable already exists, it must be editable.
acceptnulldatabooleanfalsetrueSpecifies whether to raise an error or not when null data is used.If not, a log message to PTSpy and an HTML comment is generated when null data is passed in to the data attribute. Default value is true.


Copyright 2005 Plumtree Software, Inc.