Skip to content

counter

miroshnikov edited this page Mar 27, 2015 · 1 revision

{counter} is used to print out a count. {counter} will remember the count on each iteration. You can adjust the number, the interval and the direction of the count, as well as determine whether or not to print the value. You can run multiple counters concurrently by supplying a unique name for each one. If you do not supply a name, the name “default” will be used.

If you supply the assign attribute, the output of the {counter} function will be assigned to this template variable instead of being output to the template.

Attribute Required Default Description
name No default The name of the counter
start No 1 The initial number to start counting from
skip No 1 The interval to count by
direction No up The direction to count (up/down)
print No true Whether or not to print the value
assign No n/a the template variable the output will be assigned to
{counter name='c1' start=100 skip=2 direction='down'}-
{counter name='c1'}-
{counter name='c1'}-
{counter name='c1' direction='up'}-

final number is: {counter name='c1'}

output:

100-
98-
96-
94-

final number is: 96

see also {counter} in PHP Smarty documentation

Clone this wiki locally