cvs: smarty /docs designers.sgml /plugins function.counter.php

From: Date: Fri, 03 May 2002 18:22:41 +0000
Subject: cvs: smarty /docs designers.sgml /plugins function.counter.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-101@lists.php.net to get a copy of this message
mohrt Fri May 3 14:22:41 2002 EDT Modified files: /smarty/docs designers.sgml /smarty/plugins function.counter.php Log: update counter to use name instead of id (id still works though) Index: smarty/docs/designers.sgml diff -u smarty/docs/designers.sgml:1.26 smarty/docs/designers.sgml:1.27 --- smarty/docs/designers.sgml:1.26 Fri May 3 14:14:23 2002 +++ smarty/docs/designers.sgml Fri May 3 14:22:41 2002 @@ -2649,11 +2649,11 @@ </thead> <tbody> <row> - <entry>id</entry> + <entry>name</entry> <entry>string</entry> <entry>No</entry> <entry><emphasis>default</emphasis></entry> - <entry>The id of the counter</entry> + <entry>The name of the counter</entry> </row> <row> <entry>start</entry> @@ -2699,8 +2699,8 @@ 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 id for each one. If you do not supply an id, the - default id will be used. counter was added to Smarty 1.4.0. + supplying a unique id for each one. If you do not supply a name, the + name 'default' will be used. counter was added to Smarty 1.4.0. </para> <para> If you supply the special "assign" attribute, the output of the Index: smarty/plugins/function.counter.php diff -u smarty/plugins/function.counter.php:1.2 smarty/plugins/function.counter.php:1.3 --- smarty/plugins/function.counter.php:1.2 Wed Feb 20 17:24:32 2002 +++ smarty/plugins/function.counter.php Fri May 3 14:22:41 2002 @@ -13,47 +13,52 @@ static $count = array(); static $skipval = array(); static $dir = array(); - static $id = "default"; + static $name = "default"; static $printval = array(); static $assign = ""; extract($params); - if (!isset($id)) - $id = "default"; + if (!isset($name)) { + if(isset($id)) { + $name = $id; + } else { + $name = "default"; + } + } if (isset($start)) - $count[$id] = $start; - else if (!isset($count[$id])) - $count[$id]=1; + $count[$name] = $start; + else if (!isset($count[$name])) + $count[$name]=1; if (!isset($print)) - $printval[$id]=true; + $printval[$name]=true; else - $printval[$id]=$print; + $printval[$name]=$print; if (!empty($assign)) { - $printval[$id] = false; - $smarty->assign($assign, $count[$id]); + $printval[$name] = false; + $smarty->assign($assign, $count[$name]); } - if ($printval[$id]) - echo $count[$id]; + if ($printval[$name]) + echo $count[$name]; if (isset($skip)) - $skipval[$id] = $skip; - else if (empty($skipval[$id])) - $skipval[$id] = 1; + $skipval[$name] = $skip; + else if (empty($skipval[$name])) + $skipval[$name] = 1; if (isset($direction)) - $dir[$id] = $direction; - else if (!isset($dir[$id])) - $dir[$id] = "up"; + $dir[$name] = $direction; + else if (!isset($dir[$name])) + $dir[$name] = "up"; - if ($dir[$id] == "down") - $count[$id] -= $skipval[$id]; + if ($dir[$name] == "down") + $count[$name] -= $skipval[$name]; else - $count[$id] += $skipval[$id]; + $count[$name] += $skipval[$name]; } /* vim: set expandtab: */

« previous php.smarty.cvs (#101) next »