number_format modifier for Template_Lite
Feb.18, 2011 in
PHP
Anyone else puzzled why the Template_Lite template engine for PHP does not include a number_format modifier by default? I was. I googled and didn’t find one in my short search so here it is:
function tpl_modifier_number_format($number, $decimals)
{
if(!empty($number))
{
return number_format($number, $decimals);
}
else
{
return number_format(0, $decimals);
}
}
Just save that into the template_lite/plugins folder as modifier.number_format.php and you’re all set. Now you can use this in your templates:
{$currentPrice|number_format:2}

Leave a Reply