10 * Smarty {counter} function plugin
14 * Purpose: print out a counter value
15 * @author Monte Ohrt <monte at ohrt dot com>
16 * @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
17 * (Smarty online manual)
18 * @param array parameters
22 function smarty_function_counter($params, &$smarty)
24 static $counters = array();
26 $name = (isset($params['name'])) ?
$params['name'] : 'default';
27 if (!isset($counters[$name])) {
28 $counters[$name] = array(
35 $counter =& $counters[$name];
37 if (isset($params['start'])) {
38 $counter['start'] = $counter['count'] = (int)$params['start'];
41 if (!empty($params['assign'])) {
42 $counter['assign'] = $params['assign'];
45 if (isset($counter['assign'])) {
46 $smarty->assign($counter['assign'], $counter['count']);
49 if (isset($params['print'])) {
50 $print = (bool)$params['print'];
52 $print = empty($counter['assign']);
56 $retval = $counter['count'];
61 if (isset($params['skip'])) {
62 $counter['skip'] = $params['skip'];
65 if (isset($params['direction'])) {
66 $counter['direction'] = $params['direction'];
69 if ($counter['direction'] == "down")
70 $counter['count'] -= $counter['skip'];
72 $counter['count'] +
= $counter['skip'];
78 /* vim: set expandtab: */
This page took 0.871678 seconds and 4 git commands to generate.