VirtueMart - 1.1 Developer's Guide

Page of 44
Templates
12
A template is a file holding HTML and PHP code for displaying a page or a part of it. Example: the
file 
/templates/product_details/flypage.tpl.php
. It is used to display details of a
product.
3.1.2.2. Placeholders or Variables?
You might want to know which placeholders or variables are available to style and display certain
details...well that differs from template to template. The reason for this is that all variables must be
imported into the template before you can use them. Most important: there are no more placeholders
like {product_name} as used in VirtueMart 1.0.x. All details are avalaible in PHP variables. So all
you need to know is: which variables can be used in what template and how can I use them?
Use PHP in the template
If you want to output the value of a variable all you need to do is add PHP brackets and echo the
variable inside:
<!-- Print out the value of a variable -->
<p>Product Name: <?php echo $product_name ?></p>
Don't forget to close the PHP brackets and always use valid code. If you don't it might break your site.
Predefined Global Variables
$VM_LANG This is the global language object. It displays strings which are defined in the language
file for VirtueMart.
Usage:
<?php echo $VM_LANG->_('PHPSHOP_FLYPAGE_LBL') ?>
This would print "Product Details".
$sess
Used to build (SEF-enabled) URLs that can be used in links.
Usage:
<a href="<?php echo $sess->url( $_SERVER['PHP_SELF'] .'?page=shop.product_details&amp;product_id='.$product_id ) ?>">Details...</a>
Predefined Variables for the Flypage / Product Details Template
product_name
The Product Name
product_sku
The Product SKU
product_s_desc
The Product Short Description
product_description
The Product Description
product_weight_uom
The Product Weight's unit of measure
product_length
The Product Length
product_height
The Product Height
product_width
The Product Width
product_lwh_uom
The Unit of Measure for the Product Length,Width,Height