Difference between revisions of "Available Smarty Functions"

From TMM Wiki
Jump to navigationJump to search
(Created page with "<!--Available Built-in Smarty Functions: * count * strtolower * strtoupper * number_format * date_format * array * list * isset * empty * sizeof * in_array * is_array * is_nu...")
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!--Available Built-in Smarty Functions:
+
===Available Built-in Smarty Functions:===
  
 
* count
 
* count
Line 21: Line 21:
 
* array_key_exists
 
* array_key_exists
  
Available TMM Smarty Modifiers:
+
===Available TMM Smarty Modifiers:===
*dhms
+
* dhms : Used to get the days:hours:minutes:seconds from seconds
 +
<pre>
 +
{assign var=b value='1234567890'}
 +
{$b|dhms} // returns: 14288d 23h 31m 30s
 +
</pre>
 +
* tmm_abbreviate : Used to abbreviate a string
 +
<pre>
 +
{assign var=c value='as soon as possible'}
 +
{$c|tmm_abbreviate} // returns: asap
 +
</pre>
 +
* maxlength : Used to restrict a string to the max length
 +
<pre>
 +
{assign var=d value='The quick brown fox jumps over the lazy dog'}
 +
{$d|maxlength:10} // returns: The quick bro...
 +
</pre>
 +
* multiple : Used to change the string used to break apart an array
 +
<pre>
 +
</pre>
 +
* ucwords : Used to convert the first character of each word in a string to uppercase
 +
<pre>
 +
{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
 +
</pre>
 +
* currency_format : used to display a number in its proper currency format
 +
<pre>
 +
{assign var=g value='12345'}
 +
{$g|currency_format} // returns: $12,345.00
 +
</pre>
 +
* currency_format_cents : Used to display a number in its proper currency format where currency is in cents
 +
<pre>
 +
{assign var=g value='12345'}
 +
{$h|currency_format_cents} // returns: $123.45
 +
</pre>
 +
* math_opposite : Used to change the sign for a number
 +
<pre>
 +
{assign var=h value='12345'}
 +
{$h|math_opposite} // returns: -12345
 +
</pre>
 +
* stats_date_format : Used to display a date in YYYYMMDDHHMMSS format
 +
<pre>
  
$tPSn . _abbreviate
+
</pre>
* tmm_abbreviate
+
* tmm_date_format : Used to get the format of a date
 +
<pre>
  
* maxlength
+
</pre>
* multiple
+
* tmm_local_date :  Used to get the local format of a date
* ucwords
+
<pre>
* currency_format
 
* currency_format_cents
 
* math_opposite
 
* stats_date_format
 
  
$tPSn . _date_format
+
</pre>
*tmm_date_format
+
* bytes : Used to format a number of bytes into a readable number
 
+
<pre>
$tPSn . _local_date
+
{assign var=j value='12345'}
* tmm_local_date
+
{$j|bytes} // returns: 12.06 Kb
 
+
</pre>
* bytes
+
* long2ip :  Used to convert a long integer address into a string in (IPv4) Internet standard dotted format
* long2ip
+
<pre>
* convlang
+
{assign var=k value="2071690107"}
* tmm_strpos
+
{$k|long2ip} // returns: 123.123.123.123
* tmm_strstr
+
</pre>
* rand
+
* convlang : Used to take in a string and find the valid language version
-->
+
<pre>
 +
{assign var=l value="description"}
 +
{$l|convlang} // returns: Beschreibung where "decription" exists in the language file
 +
</pre>
 +
* tmm_strpos : Used to return the position of the first occurrence of a string inside another string
 +
<pre>
 +
{assign var="m" value="http://google.com/search/this/site"}
 +
{$m|tmm_strpos:'/'} // returns: 5
 +
or reverse
 +
{$m|tmm_strpos:'/':1} // returns: 29
 +
</pre>
 +
* tmm_strstr : Used to get the first occurrence of a string inside another string <!--NATS-745-->
 +
<pre>
 +
{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/
 +
</pre>
 +
* tmm_substr : Used to cut a part of a string from a string, starting at a specified position. <!--NATS-745-->
 +
<pre>
 +
{assign var="a" value="abc@123.com"}
 +
{$a|tmm_substr:0:6} // returns: abc@12
 +
or inverse
 +
{$a|tmm_substr:-4:4} // returns: .com
 +
</pre>
 +
* rand : Used to get a random number with a min and max limit
 +
<pre>
 +
</pre>

Latest revision as of 15:03, 18 December 2017

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