Craig Brass Systems Forum: Template Variables - Craig Brass Systems Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Template Variables

#1
User is offline   Craig Brass 

  • Staff - Managing Director and Chief Software Architect
  • PipPipPip
  • Group: Management
  • Posts: 349
  • Joined: 17-January 07
Template Variables are a nice way to show something such as a certification mark to particular products.

For example, say an organisation certified individual products you sell and had a page on their site and a certification image for each of these products, you could use Template Variables to show this rather than adding database fields and stopping you from being able to easily upgrade Viper Cart.

To use, just paste and change some of the following examples into the product templates.

If Empty for Product
The following statement allows you to only show something if something has been entered for a particular variable for a product.
CODE
<?
if (!empty($Variables['test'])) {
?>
TEXT HERE
<?
}
?>


If and Else
The following statement allows you to say if a value is one thing, show this and else.
CODE
<?
if (isset($Variables['test']) && $Variables['test'] == "Gold") {
?>
TEXT HERE
<?
} elseif (isset($Variables['test']) && $Variables['test'] == "Silver") {
?>
TEXT HERE
<?
} else {
?>
TEXT HERE
<?
}
?>


Show Value
The following just prints the value of a template variable for that product. Make sure you surround it with an if statement to avoid undefined errors.
CODE
<?=$Variables['test']?>

Craig Brass
Managing Director and Chief Software Architect - Craig Brass Systems
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users