VirtueMart - 1.1 Developer's Guide

Page of 44
Templates
15
files
The object list of all addtional files this product has
buttons_header
The PDF, Email and Print buttons
browsepage_header
The heading, the category description
parameter_form
The Parameter search form
orderby_form
The sort-by, order-by form PLUS top page navigation
navigation_pathway
The pathway to the product (Power Tools # Outdoor Tools # Chain
Saw)
navigation_childlist
The  child  categories  for  the  current  category  (this  product  is
located in)
browsepage_footer
The footer with page navigation and result counter
3.1.2.3. Using and "Fetching" Templates
Create a template object
First of all, the template object must be created as an instance of the class vmTemplate.
//Create an object of the class vmTemplate
$tpl = vmTemplate::getInstance(); 
Import variables into the template
If you want to use a certain variable in your template you must import it before! Templates don't have
the global scope. So all variables are not available in a template unless you "import" them. This can
be done using the set method from the controller file (e.g. "shop.browse.php"):
Importing a variable into the template
## Syntax: $tpl->set( 'This_is_the_variableName_available_in_the_template', $theOtherVariable ); 
$tpl->set( 'product_name', $product_name ); 
The  variable  $product_name  is  just  an  example.  You  must  care  to  get  the  variables  from  the
database!  The  browse  page  offers  an  database  object  holding  all  important  product  information:
$db_browse. So if you need to access the "product_weight" or whatever value, you need to call $tpl-
>set( 'product_weight', $db_browse->f('product_weight') ); in order to get the correct value.
Parse the template
If you have finished importing all needed variables into the template object, you can "fetch" it using
this syntax:
// Parse a template
$contents = $tpl->fetch( 'product_details/myFlypage.tpl.php' );
// Print out the contents
echo $contents;
 
// Alternative: Fetch a cached template (caches if no cached copy available and Caching is turned on)
$contents = $tpl->fetch_cache( 'product_details/myFlypage.tpl.php' );
// Print out those contents
echo $contents;