PHP Classes

File: example/templates/order.tpl

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Helmut Daschnigrum  >  DirecTemplate  >  example/templates/order.tpl  >  Download  
File: example/templates/order.tpl
Role: Auxiliary data
Content type: text/plain
Description: Example script order template
Class: DirecTemplate
Template engine based on regular expressions
Author: By
Last change:
Date: 9 years ago
Size: 2,488 bytes


Class file image Download
<div class="heading">Client Information</div>

<table cellspacing="1" cellpadding="2" border="0" width="300" class="info">

<!-- display the client name -->
	<td>Client name:</td>

<!-- display the client phone number -->
	<td>Client phone number:</td>

<div class="heading">Products Ordered</div>

loop through all the products, displaying each one; this would be similar to
using "foreach ($products as $product)" from PHP.

<table cellspacing="1" cellpadding="2" border="0" width="300">

	<th>Product Name</th>
	<th class="price">Price</th>

{loop $product=$products}
everything inside the loop block is executed repeatedly - once for each item in $products;
if this is unclear, just do a view-source in your browser to see the generated page

<!-- templates also support conditionals - see below for details -->
<tr class="row_{if $_loop.odd}odd{else}even{/if}">

		$_loop contains various useful information about the loop... here, we display the
		number for each iteration of the loop

		elements of an array are accessed using "." - eg: {$} would 
		be the equivalent of $product['id'] in PHP 


	<td class="price">
		{$product.price}<br />
		<!-- you can do simple conditionals as shown below -->
		{if $product.price>50}
		<span style="color: red">Expensive!</span>
		note that you can't do complex things like AND and OR - checks like
		that are classified as logic, and should be separate from presentation
	<td style="background-color: {if $_loop.key=="red"}#FF0000{elseif $_loop.key=="blue"}#0000FF{elseif $_loop.key=="purple"}#FF00FF{else}#FFFFFF{/if}">
		<!-- $_loop.key always contains this item's key in the array -->



<div class="heading">Client Company and E-mail</div>

You can also manipulate variables using a number of built-in functions, by
appending a pipe, a function name, and optional parameters to the end of
the variable name.

Lower case: {$company|strtolower}<br />
Upper case: {$company|strtoupper}<br />
HTML Entities: {$company|htmlentities}<br />
URL Encode: {$company|urlencode}<br />
Substring: {$company|substr:2:7}<br /><br />

Obfuscated E-mail: {$email|preg_replace:/@/: at }