PHP Classes

File: example/templates/order.tpl

Recommend this page to a friend!
  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: 16 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 --> <tr> <td>Client name:</td> <td>{$name}</td> </tr> <!-- display the client phone number --> <tr> <td>Client phone number:</td> <td>{$phone}</td> </tr> </table> <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"> <tr> <th>#</th> <th>ID</th> <th>Product Name</th> <th class="price">Price</th> <th>Color</th> </tr> {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}"> <td> <!-- $_loop contains various useful information about the loop... here, we display the number for each iteration of the loop --> {$_loop.iteration} </td> <td> <!-- elements of an array are accessed using "." - eg: {$} would be the equivalent of $product['id'] in PHP --> {$} </td> <td>{$}</td> <td class="price"> {$product.price}<br /> <!-- you can do simple conditionals as shown below --> {if $product.price>50} <span style="color: red">Expensive!</span> {/if} <!-- 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> <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 --> {$_loop.key} </td> </tr> {/loop} </table> <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 }