Designers - foreach Loops
You may iterate over blocks of HTML code when displaying lists of information such as rows within a data table by using the <s:foreach>
tag, for example:
<s:foreach name="users" item="user">
Username is ~user.username~, full name is ~user.full_name~ and e-mail address is ~user.email~
</s:foreach>
The above will loop through all items within the "users" block, and copy the table row of HTML while replacing the necessary variables. Again, please consult with the back-end developers for the exact block names and variables the templates will support.
The <s:foreach>
tag supports two attributes:
Attribute | Required | Description |
---|---|---|
name | Yes | The block name as provided by the back-end developers. |
item | No | Optional name of the array name used within the merge fields. If left blank, defaults to the "name" attribute. |