Skip to content
Umakant Patil edited this page Aug 14, 2017 · 2 revisions

This is a way to format strings, such as decimal numbers and such. Use the syntax for sprintf() for the formatting.

This modifier uses Javascript port of PHP function sprintf(). You can find one at phpjs.org

Parameter Position Type Required Default Description
1 string Yes n/a This is what format to use. (sprintf)

Template:

{$articleTitle = 23.5787446}

{$number}
{$number|string_format:"%.2f"}
{$number|string_format:"%d"}

output:

23.5787446
23.58
23

see also string_format in PHP Smarty documentation

Clone this wiki locally