Prev   Next

Chapter 3. Modifying the Layout

Table of Contents

3.1. Themes and Templates
3.2. Finding the right File
3.3. Modifying Templates

The most important part of the Layout of your Shop is the Joomla template (Joomlahut.com is a good start)!

Starting with version 1.1, VirtueMart offers to style the shop using themes and templates.

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?

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

product_url

The Product URL

product_in_stock

The Number of Products currently in Stock

product_available_date

The UNIX Timestamp for the Product Availability Date

product_special

Y or N, is the product on special?

product_discount_id

The Product's Discount ID

cdate

The Product's Creation Date (UNIX Timestamp)

mdate

The Product's last Modification Date (UNIX Timestamp)

product_sales

The Number of Sales of this Product

product_unit

The Product's Packaging Unit

product_packaging

The Number of Products per Package

product_price_lbl

The price label; "Price:"

product_price

The completely formatted product price

product_price_raw

The product price array (holding the product_price, product_currency and product_price_id

product_packaging

Product Packaging information

file_list

The list of additional files for this product (when the product has files assigned to it)

product_availability

The formatted product availability information from themes/default/templates/common/availability.tpl.php; includes the "number of products in stock" and the average delivery time; template file: "common/availability.tpl.php"

product_availability_data

The raw product availability data as array; holds the "product_id", "product_available_date" (unix timestamp), "product_availability" (the string pointing to an image or just a description), "product_in_stock" (number).

addtocart

The Add-To-Cart Button Code

product_type

Product Parameter Values

product_reviews

The List of Product Reviews

product_reviewform

The Form to post a new Product Review

product_image

The small product image; complete image tag; wrapped into an URL when available.

product_full_image

The relative filename of the product full image (relative to /components/com_virtuemart/shop_image/products/

product_thumb_image

The relative filename of the product thumbnail image (relative to /components/com_virtuemart/shop_image/products/

buttons_header

The PDF, Email and Print buttons

navigation_pathway

The pathway to the product (Power Tools ⇒ Outdoor Tools ⇒ Chain Saw)

more_images

The link to the "Product Images" page when the product has additional product images

manufacturer_link

The link to the manufacturer info page

vendor_link

The link to the vendor info page

edit_link

The link to the product form of this product (admin only)

ask_seller

The link to the "Ask a question about this product" page

related_products

The list of related products

navigation_childlist

The child categories for the current category (this product is located in)

images

The object list of all additional images this product has

files

The object list of all additional files this product has

product_name

The Product Name

product_sku

The Product SKU

product_s_desc

The Product Short 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

product_flypage

The internal Product URL (to the details page)

product_url

The external Product URL

product_in_stock

The Number of Products in Stock

product_available_date

The fully formatted Product Availability Date

product_availability

The product availability information; includes the "number of products in stock" and the average delivery time

cdate

The Product's Creation Date (fully formatted)

mdate

The Product's last Modification Date (fully formatted)

product_price

The completely formatted product price

product_price_raw

The product price array (holding the product_price, product_currency and product_price_id

form_addtocart

The Add-To-Cart Button Code

product_rating

The average Product Rating

product_details

The string "Details"

product_full_image

The relative filename of the product full image (relative to /components/com_virtuemart/shop_image/products/

product_thumb_image

The relative filename of the product thumbnail image (relative to /components/com_virtuemart/shop_image/products/

images

The object list of all additional images this product has

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

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;