Loops¶
You can use loops to display a block of HTML code more than once. Loops are handy, if you need to display the same code several times, but different values should be used each time. Loops in Flamingo IDE are implemented by the FOREACH statement:
<!--{foreach ARRAY as ITEM }-->
HTML CODE
<!--{/foreach}-->
Attribute Description
ARRAY set of nodes found by XPath or JavaScript array ITEM array item declaration you may refer to in the loop body
In FOREACH statements, you can also use construction like INDEX =>ITEM :
<!--{foreach ARRAY as INDEX => ITEM }-->
HTML CODE
<!--{/foreach}-->
Attribute | Description |
---|---|
ARRAY | set of nodes found by XPath or JavaScript array |
ITEM | array item declaration you may refer to in the loop body |
Note
You should bear in mind, that numbering in this construction starts from 0.
Note
foreach should be written in lowercase letters. Using uppercase letters (FOREACH) will result in error.
You can add condition code for easy editing automatically by clicking the FOREACH loop button on the Code Editor toolbar .
Usage Examples¶
Use links below to see some sample situations where loops can be used.
Example 1 : Display the List of Brands by Inline API Calls
Shows how to display the list of brands by inline API calls.
Example 2 : Display the List of Product Categories Using Nested Template Parameters
Shows how to display the list of product categories using nested template parameters.
Example 3 : Display the Current Category Number
Shows how to display category numbers using the INDEX =>ITEM construction.
Example 4 : Displaying Definite Array Elements
Shows how to display required array elements.