register_function

void register_function (string name, string impl)

Use this to dynamically register template function plugins. Pass in the template function name, followed by the PHP function name that implements it.

Пример 13-22. register_function

$smarty->register_function("date_now", "print_current_date");

function print_current_date ($params) {
    extract($params);
    if(empty($format))
        $format="%b %e, %Y";
    echo strftime($format,time());
}

// now you can use this in Smarty to print the current date: {date_now}
// or, {date_now format="%Y/%m/%d"} to format it.