Cert++
Close

Iterating collections with isloop and its status object

Key Takeaway

In an <isloop>, the loop status object's count is the number of iterations the loop actually performs, starting at 1. index is the item's position in the collection, so the two differ when begin is greater than 0.

The <isloop> tag repeats a block of ISML template markup once for each element in a collection, such as a list of categories, products, shipping methods, or payment methods. An optional loop status object tells the template where it is in the loop. The tags <isbreak/>, <isnext/>, and <iscontinue/> change how the loop moves forward.

How to loop through a collection

The <isloop> tag loops through the elements of an iterator and outputs its body once per element. You can nest <isloop> statements inside one another.

  1. Name the collection with exactly one of the items or iterator attributes. Never use both. Each takes an expression that returns the object to iterate over. The two attributes are interchangeable, but items is preferred.
  2. Name the current element with exactly one of the var or alias attributes. Never use both, and prefer var. The variable points to the element being processed in the current iteration.
  3. Put the markup to repeat inside the loop body. Use the variable there to read the current element.
<isloop items="${pdict.Articles}" var="article">
    <isprint value="${article.title}">
</isloop>

Here items points the loop at pdict.Articles. var names the current element article, so the body prints one article title per pass.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a development task, code ISML templates that use functionality, such as local include, remote include, components, and other ISML tags

0/14

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers.