public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
    {
        if (isset($tpl->tpl_function[$name])) {
            if (!$tpl->caching || ($tpl->caching && $nocache)) {
                $function = $tpl->tpl_function[$name]['call_name'];
            } else {
                if (isset($tpl->tpl_function[$name]['call_name_caching'])) {
                    $function = $tpl->tpl_function[$name]['call_name_caching'];
                } else {
                    $function = $tpl->tpl_function[$name]['call_name'];
                }
            }
            if (function_exists($function)) {
                $function ($tpl, $params);
                return;
            }
            // try to load template function dynamically
            if ($this->addTplFuncToCache($tpl, $name, $function)) {
                $function ($tpl, $params);
                return;
            }
        }
        throw new SmartyException("Unable to find template function '{$name}'");
    }