Available Smarty Functions

From TMM Wiki
Revision as of 15:03, 18 December 2017 by TMM Rich (talk | contribs) (→‎Available TMM Smarty Modifiers:)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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... 
  • multiple : Used to change the string used to break apart an array

  • 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
  • stats_date_format : Used to display a date in YYYYMMDDHHMMSS format

  • tmm_date_format : Used to get the format of a date

  • tmm_local_date : Used to get the local format of a date

  • 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="http://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="http://google.com/search/this/site"}
{$n|tmm_strstr:'search'} // returns: search/this/site
or inverse
{$n|tmm_strstr:'search':1} // returns: http://google.com/
  • tmm_substr : Used to cut a part of a string from a string, starting at a specified position.
{assign var="a" value="abc@123.com"}
{$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