|
|
<< Back to index
Template Functions
The followings are template functions that can be used in template.
Function ${cfg(MODULE, NAME)}
This function can be used in a template to get configuration values.
Usage
${cfg('DATE_FORMAT')}
${cfg('DATETIME_FORMAT')}
${cfg('SHOP', 'CURRENCY')}
Function ${date_format(value, format)}
This function can be used in a template to display date or datetime value into a desired format.
Usage
${date_format(${date_value}, 'dd/mm/yyyy')}
${date_format(${date_value}, 'dd-mm-yyyy hh:mi:ss')}
${date_format(${date_value}, 'yyyy')}
Assume the ${date_value} is holding the value 01 Aug 2009, 01:20AM
the example above will give you the following output.
01/08/2009
01-08-2009 01:20:00
2009
Function ${label(text, arg1, arg2, arg3...)}
This function can be used in a template to retrieve a label base on the language setting.
The purpose is to let your website display text in multilingual when user change language.
For more information how you can edit multilingual text, please read more about
multilingual support.
Usage
${label("Hello world!")}
${label("My name is {0} {1}.", "Jojo", "Miller")}
From the second example above, "Jojo" and "Miller" are the argument that will be placed in the position {0} and {1}.
The argument number could holds an incremental integer number like {0} {1} {2} {3} {4} {5}... and so on.
The above output will give you
Hello world!
My name is Jojo Miller.
Function ${page(page_alias)}
This function can be used in a template to get the full url path of a page.
Usage
${page("my_new_page")}
From the example above, assume it isa static page, the output will give you
http://www.yourdomain.com/en/html/my_new_page.htmbr>
Function ${path(attributes)}
This function can be used in a template to get the navigation path of an action.
Usage
${path(maximum=3, separator=' > ')}
${path(maximum=5, separator=" <img src='image/path_separator.gif'> ")}
From the example above, the output will give you
Page > Home > Some page 1
Page Home Some page 1 Some page 2 Some page 3
Attributes
- maximum - The maximum layer to be shown
- separator - The separator to be used to separate the page elements.
Function ${price(price, currency_code)}
This function can be used in a template to format price according to the international currency code defined in ISO-4217.
Usage
${price("1289.50", "NOK")}
${price("499.90", "USD")}
${price("350.90", "AUD")}
${price("19800.00", "JPY")}
${price("988.00", "MYR")}
From the example above, the output will give you
NOK 1289.50 kr
$ 499.90 USD
AU$ 350.90
¥ 19800.00
RM 988.00
Function ${random(min, max)}
This function can be used in a template to get a random number.
Usage
${random(10, 9999)}
From the example above, the output will give you a random between 10 to 9999.
Function ${substr(string, offset, length)}
This function is used to return a substring from the expression and returns the value starts from the offset till the desired length of characters.
If offset is negative, starts that far from the end of the string.
If length is omitted, returns everything till the end of the string.
Usage
${substr("Hello world! Welcome to Greece.", 13, 30)}
${substr(${some_value}, 2, 6)}
The example above will give you the following output
Welcome to Greece.
Function ${url(path)}
This function can be used in a template to get the full url path of an action.
Usage
${url("user-auth-login")}
From the example above, the output will give you
http://www.yourdomain.com/cgi-bin/page/user-auth.login.gobr>
|
|