summaryrefslogtreecommitdiff
path: root/lib/smarty-plugins/function.varvar.php
blob: 36c9776e0d3245ef0d0aeb5122058df9d2217645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
/**
 * Smarty {varvar} function plugin
 *
 * Type:     function
 * Name:     varvar
 * Purpose:  Assume the input is a string, and if a smarty variable with that name
 *          is set, return its value. Otherwise, return the original string
 * @param array
 * @param Smarty
 */
function smarty_function_varvar($params, &$smarty) {
    $value = $smarty->getTemplateVars();
    $ret = $value[$params['var']];
    if ($ret) {
        return $ret;
    } else {
        return $params['var'];
    }
}
?>