Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of David Agar  >  Templateze  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example code
Class: Templateze
Template engine based on replacement processing
Author: By
Last change:
Date: 2004-10-02 11:48
Size: 1,382 bytes
 

Contents

Class file image Download
<?php
// initialize class and set template
include("templateze.php");
$tpl = new templateze("./example.html");

// build demo vars
$var1 "Variable 1 Replaced OK";
$var2 "Variable 2 Replaced OK";
$var3 "Variable 3 Replaced OK";

///// set variables /////
$tpl->set("var1|$var1");
//change tags //
$tpl->tagchange("%");
$tpl->set("var2|$var2");
$tpl->tagchange("@@");
$tpl->set("var3|$var3");

$tpl->tagchange("~");

///// Loop Example /////
// build demo loop array data
// Note: array variable name is the loop id name within the html
$table_rows = array();
        
$table_rows[] = array( 'id' => '1',
                               
'first_name' => 'John',
                               
'surname' => 'Smith'
                             
);

        
$table_rows[] = array( 'id' => '2',
                               
'first_name' => 'Bill',
                               
'surname' => 'Jones'
                             
);

        
$table_rows[] = array( 'id' => '3',
                               
'first_name' => 'Tom',
                               
'surname' => 'Robins'
                             
);
// set loop //
$tpl->setloop("table_rows");

///// Insert Blocks from file /////
$tpl->tplblock("header|./template_head.html");
$tpl->tplblock("sidebar|./template_side.html");

//display template
echo $tpl->display();
?>