aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/docs/designers/language-custom-functions/language-function-counter.md
blob: cc1ac08f2a8b500b7c71a52ed8413a6c75ce8b13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{counter} {#language.function.counter}
=========

`{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 Name    Type     Required    Default   Description
  ---------------- --------- ---------- ----------- ------------------------------------------------------
        name        string       No      *default*  The name of the counter
       start        number       No         *1*     The initial number to start counting from
        skip        number       No         *1*     The interval to count by
     direction      string       No        *up*     The direction to count (up/down)
       print        boolean      No       *TRUE*    Whether or not to print the value
       assign       string       No        *n/a*    the template variable the output will be assigned to


    {* initialize the count *}
    {counter start=0 skip=2}<br />
    {counter}<br />
    {counter}<br />
    {counter}<br />

      

this will output:


    0<br />
    2<br />
    4<br />
    6<br />