Smarty stock plugins

Contents...

Functions

Modifiers

{wa_header}

Generates main backend navigation menu.

Example

{wa_header}

{wa_pagination}

Generates pagination links.

Parameters

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

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

Example

{1400248772|wa_date}

Result

05/16/2014

{...|wa_datetime [:'format'[:'timezone'[:'locale']]]}

Formats specified UNIX timestamp as date and time.

Parameters

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

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

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

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

Example

{123456|wa_format_number:3:'en_US'}

Result

123,456.000

{...|wa_format [:'decimals']}

Formats a number as required by current locale.

Parameters

Example

{123456|wa_format:3}

Result

123,456.000 //in this example default locale is en_US