PKPTemplateManager::smartyIterate PHP Method

smartyIterate() public method

Parameters: - from: Name of template variable containing iterator - item: Name of template variable to receive each item - key: (optional) Name of variable to receive index of current item
public smartyIterate ( $params, $content, $smarty, &$repeat )
    function smartyIterate($params, $content, $smarty, &$repeat)
    {
        $iterator =& $smarty->get_template_vars($params['from']);
        if (isset($params['key'])) {
            if (empty($content)) {
                $smarty->assign($params['key'], 1);
            } else {
                $smarty->assign($params['key'], $smarty->get_template_vars($params['key']) + 1);
            }
        }
        // If the iterator is empty, we're finished.
        if (!$iterator || $iterator->eof()) {
            if (!$repeat) {
                return $content;
            }
            $repeat = false;
            return '';
        }
        $repeat = true;
        if (isset($params['key'])) {
            list($key, $value) = $iterator->nextWithKey();
            $smarty->assign_by_ref($params['item'], $value);
            $smarty->assign_by_ref($params['key'], $key);
        } else {
            $smarty->assign_by_ref($params['item'], $iterator->next());
        }
        return $content;
    }