- <?php
- /*include the class*/
- include_once('../class.XiTemplate.php');
-
- /*instantiate the class and pass the path to your html template file*/
- $xitpl = new XiTemplate('templates/parse.tpl');
-
- /*assign a value to a template variable.*\
- /*In this example {NAME} will be replaced with "XiTemplate"*/
- $xitpl->assign('NAME', 'XiTemplate');
-
- /*let's make dynamically make a table*/
- $rows = 3;
- $cols = 4;
-
- for ($i = 0; $i < $rows; $i++) /*loop to make the tr's*/
- {
- for ($x = 0; $x < $cols; $x++) /*loop to make the td's*/
- {
- $xitpl->assign('VARIABLE', 'row: '.($i+1).', column: '.($x+1));
- /*notice the hierarchy by which blocks must be parsed...*/
- $xitpl->parse('main.tr.td');
- }
- /*...always parse child blocks first*/
- $xitpl->parse('main.tr');
- }
-
- /*parse the "main" block of the template (the whole page)*/
- $xitpl->parse('main');
-
- /*send the final page out to the browser*/
- $xitpl->out('main');
- ?>