Location: PHPKode > scripts > Templateze > templateze/example.php
<?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();
?>
Return current item: Templateze