Difference between revisions of "Available Smarty Functions"

From TMM Wiki
Jump to navigationJump to search
Line 22: Line 22:
  
 
===Available TMM Smarty Modifiers:===
 
===Available TMM Smarty Modifiers:===
* dhms
+
* dhms : Used to get the days:hours:minutes:seconds from seconds
* tmm_abbreviate
+
<pre>
* maxlength
+
{assign var=b value='1234567890'}
* multiple
+
{$b|dhms} // returns: 14288d 23h 31m 30s
* ucwords
+
</pre>
* currency_format
+
* tmm_abbreviate : Used to abbreviate a string
* currency_format_cents
+
<pre>
* math_opposite
+
{assign var=c value='as soon as possible'}
* stats_date_format
+
{$c|tmm_abbreviate} // returns: asap
* tmm_date_format
+
</pre>
* tmm_local_date
+
* maxlength : Used to restrict a string to the max length
* bytes
+
<pre>
* long2ip
+
{assign var=d value='The quick brown fox jumps over the lazy dog'}
* convlang
+
{$d|maxlength:10} // returns: The quick bro...
* tmm_strpos
+
</pre>
* tmm_strstr
+
* multiple : Used to change the string used to break apart an array
* tmm_substr
+
<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>
 +
 
 +
</pre>
 +
* tmm_date_format : Used to get the format of a date
 
<pre>
 
<pre>
{assign name="$a" value="cho_test@abc.com"}
 
  
{$a|tmm_strstr:"@":true}  or
 
{$a|tmm_strstr:"@"}
 
 
</pre>
 
</pre>
* rand
+
* tmm_local_date :  Used to get the local format of a date
-->
+
<pre>
 +
 
 +
</pre>
 +
* bytes : Used to format a number of bytes into a readable number
 +
<pre>
 +
{assign var=j value='12345'}
 +
{$j|bytes} // returns: 12.06 Kb
 +
</pre>
 +
* long2ip :  Used to convert a long integer address into a string in (IPv4) Internet standard dotted format
 +
<pre>
 +
{assign var=k value="2071690107"}
 +
{$k|long2ip} // returns: 123.123.123.123
 +
</pre>
 +
* 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
 +
<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.
 +
<pre>
 +
{assign name="$a" value="abc@123.com"}
 +
{$a|tmm_strstr:"@"} // returns: @123.com
 +
or inverse
 +
{$a|tmm_strstr:"@":true} // returns: abc
 +
</pre>
 +
* rand : Used to get a random number with a min and max limit
 +
<pre>
 +
</pre>

Revision as of 00:11, 8 November 2017