VTE: Getting Started

Since VTE is embedded inside Vivvo Templates .tpl files, that must be valid xHTML Transitional documents, we will skip “Hello World!” example.

VTE Tags (instructions)

VTE has only 14 instructions for loading and manipulating data, assigning custom JS and CSS, building control structures. In order to fetch specific data, VTE usually interacts with Vivvo Modules, such as box_article_list.

Variable Modifiers

Variable modifiers can be applied to variables. To apply a modifier, specify the value followed by a | (pipe) and the modifier name. A modifier may accept additional parameters that affect its behavior. These parameters follow the modifier name and are separated by a : (colon). Also, all PHP built-in functions as well as custom PHP functions can be used as modifiers.

Variable modifier syntax is as follows

"{<VTE_function> | <modifier_function> : <additional_params>}"

Here are few simple modifier examples:

{* applying modifier to a variable *}
<vte:value select="{article.get_title|strtoupper}" />

{* using format_date to format the current date *}
<vte:value select="{article.created|format_date:'d/m/Y'}" />

{* counting the number of elements in a list *}
<vte:value select="{article_list|count}" />

{* using PHP built-in function as modifier for query parameter  *}
<vte:param name="search_cid" value="{CURRENT_CATEGORY.get_id},{CURRENT_CATEGORY.get_descendent_ids|implode:','}" /> 

{* forcing number of characters for article abstract text  *}
<vte:value select="{article.get_summary|NUMBER_OF_CHARACTERS}" />

Accessing array elements and Chaining Object methods

Chaining Object methods is introduced in Vivvo 4.1 and will not work in Vivvo versions prior to it.

VTE commes with improved support for handling PHP object/arrays. Now its possible to directly access array elements referencing element of an array within square brackets '[' and ']'.

<vte:value select="{my_list[3]}" />

or even access methods of array element:

<vte:value select="{article_list[3].get_title}" />

Since Vivvo 4.1 you can also chain object methods:

<vte:value select="{article.get_category.get_image}" />

All this can be used in combination with variable modifiers.

Basic primers

Lets demonstrate how to use VTE through several examples.

Well, I guess you're on your own now :)

 
devdoc/vte/getting_started.txt · Last modified: 2010/10/06 05:28 by boccio
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki