The counter function can be used to keep track of or display a counter in the content.

Arguments

The following arguments can be used with counter:

ArgumentDescription
nameThe name of the counter.
startThe number the counter should start with, default is 0.
skipThe amount to skip per iteration.
directionThe direction of counting: up or down.
printA boolean value to determine whether to display the current value of the counter.
assignThe option to store the current counter value in a variable.

Examples

counter

{{counter}}
{{counter}}

Output:

1
2

Advanced counter

{{counter name="counter1" start=9 skip=3 direction="down"}}
{{counter name="counter1"}}
{{counter name="counter1"}}
{{counter name="counter1"}}

Output:

9
6
3
0

counter with foreach

{{counter assign=i start=0 print=false}}
 
{{foreach from=data item=item}}
    {{counter}} // this will increase the value +1 for variabele $i 
{{/foreach}}