Overview
Since many of the Jamroom scripts make use of the Smarty Templates, some additional Smarty “variable modifiers” and functions have been created for your use in your Jamroom templates. A Smarty variable modifier is used when you want to change the contents of a Smarty variable, by passing it to a custom “function”. For example, if you had the following in a Jamroom template:
<font face="Verdana">{$BAND_STORY}</font>
You could replace it with the following:
<font face="Verdana">{$BAND_STORY|truncate:30:"...":true}</font>
- that would truncate the output of the {$BAND_STORY} variable at 30 characters, even if it meant cutting off the output in the middle of the word, and then add “...” to the end of the resulting string.
A Smarty "Function" is an embedded function that can be run to create output:
We have {jr_counts type="bands"} artist in our Jamroom!
Would return "We have 25 artists in our Jamroom!" if you had 25 artists in your Jamroom. Custom Functions
{jr_counts}
The {jr_counts} custom Smarty function is used for retrieving "counts" from your Jamroom. It runs the same function that is used in the Jamroom "get_counts.php" script, so it accepts a "type" argument that is the same as the get_counts.php script.
Position |
Type |
Required |
Default |
Description |
1 |
string |
yes |
n/a |
The "type" argument is required to let the jr_counts script know the type of count you would like to retrieve from your Jamroom. For example, {jr_counts type="bands"} would grab the count of the number of Artist Accounts currently configured in your Jamroom. The valid "types" that can be passed to the jr_counts custom function can be:
bands streams_today downloads_today plays_today spotlights_today streams downloads plays spotlights viewers listeners ratings rating_users radio_plays radio_songs video_streams video_downloads video_plays total_video_streams total_video_downloads total_video_plays page_views videos songs users session sessions guests radio photos genre genres items store entries events messages comments guestbooks quotas servers |
Variable Modifiers
bbdecode
This variable modifier will expand any BBCode tags in the variable with their associated HTML tags.
Example “bbdecode” usage:
{$BAND_STORY|bbdecode}
html_cleanup
This variable modifier will “strip slashes” from the output. When retrieving data from a database, some special characters (such as the single quote ‘) will have a backslash placed before it (i.e. ’) to indicate that it is a special character. The problem is that if you don’t “strip slashes” the backslash will remain in the output. Use this html_cleanup to strip slashes, as well as to optionally convert all special HTML characters in to their HTML entities equivalent.
Postion |
Type |
Required |
Default |
Description |
1 |
string |
no |
“no” |
If this parameter is set to “yes”, then all special HTML characters in the output will be converted to the correct HTML Entity. |
Example “html_cleanup” usage:
{$BAND_STORY|html_cleanup:"yes"}
number_format
This variable modifier is used to format the output of numbers in Jamroom. This gives you the control you need to represent whole or fractional numbers in the format you would like (i.e. grouping thousands).
Postion |
Type |
Required |
Default |
Description |
1 |
int |
yes |
n/a |
This is the input number to be formatted. |
2 |
boolean |
no |
false |
By default decimal places are NOT shown. Set this to “true” to show decimal places. |
3 |
string |
no |
“.” |
By default a period (.) is used to represent the Decimal Seperator. Providing a different string here will override the default and be used instead. |
4 |
string |
no |
“,” |
By default a comma (,) is used to represent the Thousands Seperator. Providing a different string here will override the default and be used instead. |
Example “number_format” usage:
{$BAND_RATING|number_format:true}
{$SONG_STREAM_COUNT|number_format}
strip_html
This variable modifier will run the bbDecode() function on the variable first, to expand any BBCode into HTML tags, then strip all HTML from the output.
Example “strip_html” usage:
{$BAND_STORY|strip_html}
stripslashes
This variable modifier will “strip slashes” from the output. Sometimes, when data is retrieved from a database, you may see “slashes” before certain special characters (namely the single quote ’ - it would appear like ’). To “strip” these slashes, you would use the stripslashes modifier:
Example “stripslashes” usage:
{$BAND_STORY|stripslashes}
urldecode
This variable modifier will URL “decode” a string (see http://www.php.net/urldecode for more details on urldecoding). This in effect will convert all urlencoded characters back to their ascii equivelent.
Example “urldecode” usage:
{$BAND_NAME|urldecode}
urlencode
This variable modifier will URL “encode” a string (see http://www.php.net/urlencode for more details on urlencoding). This in effect will convert all ASCII characters that are not URL safe to their URL encoded counter parts. This makes it safe to pass the variable in a GET URL.
Example “urlencode” usage:
{$BAND_NAME|urlencode}
email_obfuscate
This variable modifier will “obfuscate” an email address so it is much more difficult for spam bots to harvest the email address from your page(s).
Example “email_obfuscate” usage:
{$USER_EMAIL|email_obfuscate}
nocaps
This variable modifer will take a string that is ALL CAPS, and make it so only the first letter of each work is capatilized. Available as of Jamroom 2.30.
Example “nocaps” usage:
{$BAND_NAME|nocaps}
convert_to_seconds
This variable modifier will take a viewable timestamp like HH:MM::SS (like is seen on the Artist Pages) and convert it into the number of seconds in a numerical format - i.e. 01:23:45 would become 5025 (the number of seconds in 1 hour, 23 minutes and 45 seconds). Available as of Jamroom 2.41.
Example “convert_to_seconds” usage:
{$SONG_HIFI_LENGTH|convert_to_seconds}
|