Functions
-
wa_header
Generates main backend navigation menu.
-
wa_pagination
Generates pagination links.
-
wa_print_tree
Generates a tree-like list from a hierarchical array of data.
Modifiers
-
wa_date
Formats specified UNIX timestamp as date.
-
wa_datetime
Formats specified UNIX timestamp as date and time.
-
wa_format_amount_currency
Formats an amount by adding a currency sign.
-
wa_format_amount
Formats an amount according to specified format and adds a currency sign.
-
wa_format_file_size
Formats a number as a file size.
-
wa_format_number
Formats a number as required by specified locale.
-
wa_format
Formats a number as required by current locale.
{wa_header}
Generates main backend navigation menu.
Example
{wa_header}
{wa_pagination}
Generates pagination links.
Parameters
-
total
Total page number.
-
page
Current page id.
-
nb
Number of links to be displayed in the opposite part of the pagination control element.
-
prev
Text to be used for the link pointing to the previous page. Default value:
←
. -
next
Text to be used for the link pointing to the next page. Default value:
→
. -
url
Main URL to be used for generating the URLs of pagination links. By default, the URL of the current page is used.
-
attrs
Associative array of HTML attributes and their values which must be added to the pagination control element (
ul
).
Example
{wa_pagination total=100 page=5 prev="«" next="»" nb=3 attrs=['class' => 'menu-h']}
Result
<ul class="menu-h"> <li><a class="inline-link" href="/webasyst/myapp/?page=4">«</a></li> <li><a href="/webasyst/myapp/">1</a></li> <li><a href="/webasyst/myapp/?page=2">2</a></li> <li><a href="/webasyst/myapp/?page=3">3</a></li> <li><a href="/webasyst/myapp/?page=4">4</a></li> <li class="selected"><a href="/webasyst/myapp/?page=5">5</a></li> <li><a href="/webasyst/myapp/?page=6">6</a></li> <li><span>...</span></li> <li><a href="/webasyst/myapp/?page=98">98</a></li> <li><a href="/webasyst/myapp/?page=99">99</a></li> <li><a href="/webasyst/myapp/?page=100">100</a></li> <li><a class="inline-link" href="/webasyst/myapp/?page=6">»</a></li> </ul>
{wa_print_tree}
Generates a tree-like list from a hierarchical array of data.
Parameters
-
tree
Array of data. If an element must have sub-elements, they must be contained in the
'childs'
property of such a parent element. -
unfolded
Flag requiring to generate an expanded tree. Default value: true. If
false
is specified, then the tree is collapsed to the maximum extent as described below:- If parameter
selected
contains a value corresponding to an element of the 2nd or lower level, then expanded is only the part of the tree which is required to display the element whoseid
is specified in parameterselected
. - Otherwise the tree contains only elements of the 1st level.
- If parameter
-
selected
id
property value belonging to the element(li
) of the tree, to which CSS class'selected'
must be assigned. -
class
Name of CSS class which must be assigned to the root tree element (
ul
). -
attrs
HTML attributes which must be added to the root tree element (
ul
). -
elem
Template for generating HTML code of the HTML element contained in each tree item (
li
). To add array item values to that HTML code, specify those property names in theelem
parameter with a colon before the property name. For example, if you need to add the value of theurl
property, specify it in the form:url
. -
collapsible_class
Name of CSS class which must be assigned to each tree element (
li
) which have a non-emptychilds
property. -
depth
Number of levels of sub-elements which must be included in the resulting tree, if the
unfolded
parameter containstrue
.
Examples
//data array array( array( 'id' => 1, 'name' => 'Footwear', 'url' => '/footwear/', ), array( 'id' => 2, 'name' => 'Apparel', 'url' => '/apparel/', 'childs' => array( array( 'id' => 3, 'name' => 'Men', 'url' => '/apparel/men/', ), array( 'id' => 4, 'name' => 'Women', 'url' => '/apparel/women/', 'childs' => array( array( 'id' => 5, 'name' => 'Skirts', 'url' => '/apparel/women/skirts/', ), array( 'id' => 6, 'name' => 'Dresses', 'url' => '/apparel/women/dresses/', 'childs' => array( array( 'id' => 7, 'name' => 'Evening gowns', 'url' => '/apparel/women/dresses/evening-gowns/', ), ), ), ), ), ), ), array( 'id' => 8, 'name' => 'Accessories', 'url' => '/accessories/', ), );
Example 1 (tree is expanded, element with id=3 is selected)
{wa_print_tree tree=$data elem='<a href=":url">:name</a>' selected=3 class="category-tree" attrs="title='Category tree'" collapsible_class="parent"}
Result
<ul class="category-tree" title="Category tree"> <li><a href="/footwear/">Footwear</a></li> <li class="parent"><a href="/apparel/">Apparel</a> <ul> <li class="selected"><a href="/apparel/men/">Men</a></li> <li class="parent"><a href="/apparel/women/">Women</a> <ul> <li><a href="/apparel/women/skirts/">Skirts</a></li> <li class="parent"><a href="/apparel/women/dresses/">Dresses</a> <ul> <li><a href="/apparel/women/dresses/evening-gowns/">Evening gowns</a></li> </ul> </li> </ul> </li> </ul> </li> <li><a href="/accessories/">Accessories</a> </li> </ul>
Example 2 (tree is expanded 1 level deep)
{wa_print_tree tree=$data elem='<a href=":url">:name</a>' selected=3 class="category-tree" attrs="title='Category tree'" collapsible_class="parent" depth=1}
<ul class="category-tree" title="Category tree"> <li><a href="/footwear/">Footwear</a></li> <li class="parent"><a href="/apparel/">Apparel</a> <ul> <li class="selected"><a href="/apparel/men/">Men</a></li> <li class="parent"><a href="/apparel/women/">Women</a></li> </ul> </li> <li><a href="/accessories/">Accessories</a></li> </ul>
Example 3 (tree is collapsed except for elements necessary to display selected element with id=5)
{wa_print_tree tree=$data elem='<a href=":url">:name</a>' class="category-tree" attrs="title='Category tree'" collapsible_class="parent" selected=5 unfolded=false}
<ul class="category-tree" title="Category tree"> <li><a href="/footwear/">Footwear</a></li> <li class="parent"><a href="/apparel/">Apparel</a> <ul> <li><a href="/apparel/men/">Men</a></li> <li class="parent"><a href="/apparel/women/">Women</a> <ul> <li class="selected"><a href="/apparel/women/skirts/">Skirts</a></li> <li class="parent"><a href="/apparel/women/dresses/">Dresses</a></li> </ul> </li> </ul> </li> <li><a href="/accessories/">Accessories</a></li> </ul>
Example 4 (tree is collapsed, only elements of the upper level are displayed)
{wa_print_tree tree=$data elem='<a href=":url">:name</a>' class="category-tree" attrs="title='Category tree'" unfolded=false}
<ul class="category-tree" title="Category tree"> <li><a href="/footwear/">Footwear</a></li> <li><a href="/apparel/">Apparel</a></li> <li><a href="/accessories/">Accessories</a></li> </ul>
{...|wa_date [:'format'[:'timezone'[:'locale']]]}
Formats specified UNIX timestamp as date.
Parameters
-
format
Format string accepted by method format of class waDateTime. If not specified, default format string 'date' is used.
-
timezone
Time zone identifier. If not specified, automatically detected locale is used.
-
locale
Locale identifier. If not specified, automatically detected time zone is used.
Example
{1400248772|wa_date}
Result
05/16/2014
{...|wa_datetime [:'format'[:'timezone'[:'locale']]]}
Formats specified UNIX timestamp as date and time.
Parameters
-
format
Format string accepted by method format of class waDateTime. If not specified, default format string 'datetime' is used.
-
timezone
Time zone identifier. If not specified, automatically detected locale is used.
-
locale
Locale identifier. If not specified, automatically detected time zone is used.
Example
{1400248772|wa_datetime}
Result
05/16/2014 16:59
{...|wa_format_amount_currency [:'currency_id'[:'locale']]}
Formats an amount by adding a currency sign.
Parameters
-
currency_id
Currency ISO3 code.
-
locale
Locale identifier. If not specified, automatically detected time zone is used.
Example
{'123456'|wa_format_amount_currency:'USD'}
Result
$123,456
{...|wa_format_amount [:'currency_id'[:'format'[:'locale']]]}
Formats an amount according to specified format and adds a currency sign.
Parameters
-
currency_id
Currency ISO3 code.
-
format
Format string accepted by method format of class waCurrency. If not specified, default format string '%' is used.
-
locale
Locale identifier. If not specified, automatically detected time zone is used.
Example
{123456|wa_format_amount:'USD':'%2i{n}'}
Result
123,456.00 dollars
{...|wa_format_file_size [:'format'[:'dimensions']]}
Formats a number as a file size.
Parameters
-
format
Format string for displaying file size value, which must be acceptable for PHP function
sprintf
. -
dimensions
String of file size measure units, comma-separated. If not specified the following string is used:
'B,KB,MB,GB'
.
Example
{123456|wa_format_file_size:'%0.2f':'bytes,kilobytes,megabytes,gigabytes'}
Result
120.56 kilobytes
{...|wa_format_number [:'decimals'[:'locale']]}
Formats a number as required by specified locale.
Parameters
-
decimals
Number of decimal signs to be displayed after the decimal separator.
-
locale
Locale identifier. If not specified, automatically detected time zone is used.
Example
{123456|wa_format_number:3:'en_US'}
Result
123,456.000
{...|wa_format [:'decimals']}
Formats a number as required by current locale.
Parameters
-
decimals
Number of decimal signs to be displayed after the decimal separator.
Example
{123456|wa_format:3}
Result
123,456.000 //in this example default locale is en_US