Source for file function.cycle.php
Documentation is available at function.cycle.php
* Smarty {cycle} function plugin
* Purpose: cycle through given values<br>
* - name = name of cycle (optional)
* - values = comma separated list of values to cycle,
* or an array of values to cycle
* (this can be left out for subsequent calls)
* - reset = boolean - resets given var to true
* - print = boolean - print var or not. default is true
* - advance = boolean - whether or not to advance the cycle
* - delimiter = the value delimiter, default is ","
* - assign = boolean, assigns to template var instead of
* {cycle values="#eeeeee,#d0d0d0d"}
* {cycle name=row values="one,two,three" reset=true}
* @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
if(!isset ($cycle_vars[$name]['values'])) {
if(isset ($cycle_vars[$name]['values'])
&& $cycle_vars[$name]['values'] != $values ) {
$cycle_vars[$name]['index'] = 0;
$cycle_vars[$name]['values'] = $values;
$cycle_vars[$name]['delimiter'] = $delimiter;
} elseif (!isset ($cycle_vars[$name]['delimiter'])) {
$cycle_vars[$name]['delimiter'] = ',';
if(!is_array($cycle_vars[$name]['values'])) {
$cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
$cycle_array = $cycle_vars[$name]['values'];
if(!isset ($cycle_vars[$name]['index']) || $reset ) {
$cycle_vars[$name]['index'] = 0;
$smarty->assign($assign, $cycle_array[$cycle_vars[$name]['index']]);
$retval = $cycle_array[$cycle_vars[$name]['index']];
if ( $cycle_vars[$name]['index'] >= count($cycle_array) - 1 ) {
$cycle_vars[$name]['index'] = 0;
$cycle_vars[$name]['index']++ ;
/* vim: set expandtab: */
|