Loops

Simple loop constructs enables iteration through various items such as news items, products, variants, countries, etc.

A loop construct begins with LoopStart(items) and ends with LoopEnd(items). The name in the parentheses defines what is being iterated. HTML code and other template tags can be put in between the two loop tags.

(Loops are only available in templates where this is explicitly stated.)

Related tags

The following two tags can be used to display some text when there are items to loop:

  • LoopStart(loop name)
  • LoopEnd(loop name)

The following tags can be used at the beginning and end of a loop. The tags will result in the loop only being displayed if the loop contains items:

  • HeaderStart
  • HeaderEnd
  • FooterStart
  • FooterEnd

The following tag can be used to display a message when there are no items in a loop:

  • EmptyLoopStart
  • EmptyLoopEnd

The following tags are available for all loops:

<!--[LoopName].LoopCounter-->
<!--[LoopName].LoopMod2-->
<!--[LoopName].LoopMod3-->
<!--[LoopName].LoopMod4-->
<!--[LoopName].LoopMod5-->

Example of usage

The following example illustrates how to use a loop construct to list products in a table:

<table>
<!--@LoopStart(Products)-->
	<tr>
		<td><!--@Ecom:Product.Name--></td>
		<td><!--@Ecom:Product.Price--></td>
	</tr>
<!--@LoopEnd(Products)-->
</table>

 The following example illustrates how to use the EmptyLoop, Header and Footer loops in a simple loop construct:

<!--@LoopStart(Name)-->
<!--@EmptyLoopStart-->No items in this loop <!--@EmptyLoopEnd-->
<!--@HeaderStart--><ul><!--@HeaderEnd-->
<li><!--@SomeLoopValue--></li>
<!--@FooterStart--></ul><!--@FooterEnd-->
<!--@LoopEnd(Name)-->

Remarks

The DwTemplateTags list only outputs the first 5 loop items if it is in a loop - to avoid huge amounts of markup.

Loops are outputtet with link to the documentation like the normal tags and can also be copied.