Available Smarty Functions

Article Topics: Smarty

Available Built-in Smarty Functions:

  • count

  • strtolower

  • strtoupper

  • number_format

  • date_format

  • array

  • list

  • isset

  • empty

  • sizeof

  • in_array

  • is_array

  • is_numeric

  • true

  • false

  • strlen

  • strpos

  • nl2br

  • array_key_exists

Available TMM Smarty Modifiers:

  • dhms : Used to get the days:hours:minutes:seconds from seconds

{assign var=b value='1234567890'}
{$b|dhms} // returns: 14288d 23h 31m 30s 
  • tmm_abbreviate : Used to abbreviate a string

{assign var=c value='as soon as possible'}
{$c|tmm_abbreviate} // returns: asap
  • maxlength : Used to restrict a string to the max length

{assign var=d value='The quick brown fox jumps over the lazy dog'}
{$d|maxlength:10} // returns: The quick bro... 
  • ucwords : Used to convert the first character of each word in a string to uppercase

{assign var=f value='The quick brown fox jumps over the lazy dog'}
{$f|ucwords} // returns: The Quick Brown Fox Jumps Over The Lazy Dog
  • currency_format : used to display a number in its proper currency format

{assign var=g value='12345'}
{$g|currency_format} // returns: $12,345.00
  • currency_format_cents : Used to display a number in its proper currency format where currency is in cents

{assign var=g value='12345'}
{$h|currency_format_cents} // returns: $123.45
  • math_opposite : Used to change the sign for a number

{assign var=h value='12345'}
{$h|math_opposite} // returns: -12345
  • bytes : Used to format a number of bytes into a readable number

{assign var=j value='12345'}
{$j|bytes} // returns: 12.06 Kb 
  • long2ip : Used to convert a long integer address into a string in (IPv4) Internet standard dotted format

{assign var=k value="2071690107"}
{$k|long2ip} // returns: 123.123.123.123
  • convlang : Used to take in a string and find the valid language version

{assign var=l value="description"}
{$l|convlang} // returns: Beschreibung where "decription" exists in the language file
  • tmm_strpos : Used to return the position of the first occurrence of a string inside another string

{assign var="m" value="https://google.com/search/this/site"}
{$m|tmm_strpos:'/'} // returns: 5
or reverse
{$m|tmm_strpos:'/':1} // returns: 29
  • tmm_strstr : Used to get the first occurrence of a string inside another string

{assign var="n" value="https://google.com/search/this/site"}
{$n|tmm_strstr:'search'} // returns: search/this/site
or inverse
{$n|tmm_strstr:'search':1} // returns: https://google.com/
  • tmm_substr : Used to cut a part of a string from a string, starting at a specified position.

{assign var="a" value="[email protected]"}
{$a|tmm_substr:0:6} // returns: abc@12
or inverse
{$a|tmm_substr:-4:4} // returns: .com
  • rand : Used to get a random number with a min and max limit

Last updated

Was this helpful?