Jamroom Logo Jamroom 5 Core
is now Open Source!
Follow Jamroom on Twitter!

This document applies to Jamroom 3 only!
For current Jamroom 4 Documentation, visit the main Jamroom Documentation section.

Customizing the Jamroom Control Panel Templates Index Template Functions for use in Jamroom Templates

Overview

Inside of Jamroom Templates, you will see the use of many different template "variables".  These variable are replaced by Jamroom with the proper data when the template is processed and presented to the viewer.  For example, you may see something like this:

{$BAND_NAME}

This is a template variable - {$BAND_NAME} will be replaced the name of the band when the visitor views the template.

There may be a time however, when a variable contains data that you do NOT want to be seen, or the variable needs to be changed in some way before presentation.  This is where Variable Modifiers come in to play.  Using a variable modifier, you can easily do things like "strip" all of the HTML from the contents of a variable, or format an epoch timestamp into a readable timestamp.

  • jr_bbdecode - replace BBCode tags with HTML equivalents.
  • jr_convert_to_seconds - convert a HH:MM:SS time stamp string to numerical equivalent in seconds.
  • jr_date_format - format an epoch time stamp into a human readable time stamp.
  • jr_email_obfuscate - modify email addresses so they are visible, but not readable by spam harvesting bots.
  • jr_format_size - take a number and turn it into a "size" representation - i.e. 1048576 becomes "1mb").
  • jr_nocaps - forces the string t not be capitalized.  Great for artist profiles that use ALL CAPS FOR EVERYTHING.
  • jr_number_format - formats a string into grouped thousands and decimal places.
  • jr_safe_truncate - truncates a string at word boundaries and ignores HTML.
  • jr_replace - inline string substitution
  • jr_split_string - split a string at a character boundary and insert split character(s).
  • jr_strip_html - strip all BBCode and HTML from variable.
  • jr_stripslashes - removes any stray backslashes () from output.
  • jr_theme_string - convert variable into the Jamroom Theme Generator string equivalent.
  • jr_urldecode - URL Decode a variable.
  • jr_urlencode - URL Encode a variable.
  • jr_wordwrap - binary and multi-byte (multi-lingual) safe string wrapper.


Jamroom includes several "custom" variable modifiers for your use in Jamroom Templates - these are in addition to the selection that is already available via Smarty:

http://smarty.php.net/manual/en/language.modifiers.php

You can also use standard PHP Functions as Variable modifiers as well.

Usage

Using a variable modifier is very easy.  You simply place the modifier name "inside" of the variable itself, and this causes the variable modification to be done directly on the variable contents.  For example, if you wanted to remove ALL of the HTML from a blog post on Jamroom, you would use something like this:

{$_blog.MESSAGE_TEXT|jr_strip_html}


If at the same time, you also wanted to ensure that any words in ALL CAPITAL LETTERS are converted to lower case letters, you can "string" variable modifiers together:

{$_blog.MESSAGE_TEXT|jr_strip_html|jr_nocaps}


You can freely "string" together as many different Variable Modifiers as you would like.

Some variable modifiers may have "parameters" that can be passed to the modifier to change how it works, or effect a different behavior then the default.  The syntax for passing in parameters is like this:

{$variable_name|modifier_name:parameter1:parameter2}


You can see that the parameters are listed after the modifier name, and are separated by colons (:).  The number of parameters accepted depends on the variable modifier.

Jamroom Custom Variable Modifiers

 

jr_bbdecode

The jr_bbdecode variable modifier is used to "expand" and BBCode tags present in the text into their HTML equivalents:

Example:

{$VARIABLE|jr_bbdecode}

 


 

jr_convert_to_seconds

The jr_convert_to_seconds modifier is used for converting a timestamp (i.e. 12:35) in MM:SS format, and converting it to the appropriate number of seconds:

Example:

{$VARIABLE|jr_convert_to_seconds}

 


 

jr_date_format

The jr_date_format modifier is used to format an epoch timestamp into a readable date/time stamp.  An epoch timestamp is an 11 digit number that consists of the number of seconds since the beginning of the computer "epoch" (01/01/1970 00:00:00).  Since this long number is not easily recognizable as a date/time string, the jr_date_format modifier is used to present a readable format.

Parameters:

Position Type Required Default Description
1 string yes n/a The first parameter to the jr_date_format modifier is the "format" the date string should take.  The formats that are used are the same formats that are used by the PHP strftime() function.  You can consult the documentation page for a list of all modifiers to construct the date string to suit your needs.  Note that Jamroom allows the use of 3 additional format modifiers:
date1 - format the date according to the first date "format" as entered in the Jamroom Config -> Date and Time Settings section.
date2 - format the date according to the first date "format" as entered in the Jamroom Config -> Date and Time Settings section.
date3 - format the date according to the first date "format" as entered in the Jamroom Config -> Date and Time Settings section
2 string no n/a The optional second argument is to set the PHP "LOCALE" for the format modifier.  A list of valid LOCALE strings can be found here:
http://www.w3.org/WAI/ER/IG/ert/iso639.htm

 

Example:

{$VARIABLE|jr_date_format:"date1"}

 


 

jr_email_obfuscate

The jr_email_obfuscate modifier is used to "obfuscate" an e-mail address so it cannot be read by "spam bots" that scan web pages looking for email addresses

Example:

{$VARIABLE|jr_email_obfuscate}

 


 

jr_format_size

The jr_format_size variable modifier is used to "format" a size string into a readable string:

Example:

{$VARIABLE|jr_format_size}

 


 

jr_nocaps

The jr_nocaps modifier is used for converting a string that is ALL CAPITAL LETTERS into a string that has the first letter in each word upper-cased.


Example:

{$VARIABLE|jr_nocaps}

 


 

jr_number_format

The jr_number_format is used to "format" a number to make it easier to read, by converting the number into grouped thousands (as an example).


Parameters:

Position Type Required Default Description
1 number yes n/a The first parameter tells Jamroom how many decimal places should be after the decimal point.
2 string no . If given, this string will be used in place of a period for the decimal point
3 string no , If given, this string will be used in place of a comma for grouping thousands

 

Example:

{$VARIABLE|jr_number_format:2}

 


 

jr_safe_truncate

The jr_safe_truncate modifier is used to "truncate" a variable that contains text, but "safely" truncate it at any HTML tag boundary so the HTML formatting of the text is not broken.

Parameters:

Position Type Required Default Description
1 number no 80 The first parameter to the jr_safe_truncate modifier tells Jamroom how many characters you want to be shown in the variable.  The default is 80 characters.
2 string no ... If given, the second parameter tells Jamroom what string to add to the end of the variable after it has been truncated.  Default is 3 periods "..."
3 true/false no false The third parameter tells Jamroom if you want to "break" the variable in mid-word.  By default this is false, so a word is not broken in the middle.

 

Example:

{$VARIABLE|jr_safe_truncate}

 



jr_replace
 

The jr_replace Variable Modifier is used for "replacing" text inline - i.e. change all occurrences of a specific string with something else.

Parameters:

Position Type Required Default Description
1 string yes n/a The first parameter tells Jamroom the "string" to search for in the contents of the variable - this is what is going to be replaced.
2 string yes n/a The second parameter tells Jamroom what to replace any found strings with.

Example:

{* replace all semi-colons with commas in string *}
{$USER_GROUP_ID|jr_replace:";":","}

 




jr_split_string

The jr_split_string variable modifier is used for "splitting" a long string into many smaller pieces, with a "join" string between.  This is often used in cases where the artist name, user name, etc. are to wide for the "container" they are being used in, and you want to be sure that if the text does not contain any natural break characters, it can still be "split" at a specific character point.

Parameters:

Position Type Required Default Description
1 number no 40 The first parameter tells Jamroom how many characters wide MAXIMUM the string can be before it is split.
2 string no -<br /> The second parameter tells Jamroom the character (or string) to insert to make the "wrap".  By default this - <br /> (a dash then HTML break).


Example:

{* split a username at 10 characters max width *}
{$USER_NICKNAME|jr_split_string:10:"-<br />"}

 


 

jr_strip_html

The jr_strip_html variable modifier is used to strip all HTML code from a given variable

Example:

{$VARIABLE|jr_strip_html}

 


 

jr_stripslashes

The jr_stripslashes modifier is used to strip any "stray" backslashes from a variable

Example:

{$VARIABLE|jr_stripslashes}

 


 

jr_theme_string

The jr_theme_string variable modifier is used to create a "file system safe" representation of a variable string, so it can used to create a file name from the given variable.  This is most often used for "linking" to pages in an Artist/Member Profile theme.

Example:

{$VARIABLE|jr_theme_string}

 


 

jr_urldecode

The jr_urldecode variable modifier is used to "URL Decode" a string that has been previously URL encoded.

Example:

{$VARIABLE|jr_urldecode}

 


 

jr_urlencode

The jr_urlencode variable modifier is used to "URL Encode" a variable so it is safe to pass in via a URL.  If the contents of a variable have any spaces, punctuation, or characters that are not safe or valid for use in a URL, then the variable must be urlencoded before it can be passed back into Jamroom via a URL string.

Example:

{$VARIABLE|jr_urlencode}

 


jr_wordwrap

The jr_wordwrap Variable Modifier is used for "wrapping" (or "breaking") a word or sentence at a specific character limit.  Instead of truncating the word or sentence however, the text is merely wrapped to the next line.  Unlike the PHP "wordwrap" function, this variable modifier is multi-language character safe.

Parameters:

Position Type Required Default Description
1 number no 75 The first parameter tells Jamroom how many characters wide MAXIMUM the string can be before it is wrapped.
2 string no <br> The second parameter tells Jamroom the character (or string) to insert to make the "wrap".  By default this an HTML break tag ( <br> ).

Example:

{* Wrap a long band name at 25 characters *}
{$BAND_NAME|jr_wordwrap:25}

Customizing the Jamroom Control Panel Templates page 123 of 185 Template Functions for use in Jamroom Templates
Solutions Products Support Community Company
Social Media Platform
Social Networking Software
Musician Website Manager
Community Builder
Jamroom 5
Jamroom 5 Modules
Jamroom Marketplace
Support Forum
Documentation
Support Center
Contact Support
Community Forum
Member Sites
Developers
About Us
Contact Us
Privacy Policy
©2003 - 2024 The Jamroom Network