- <?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/nullValue.tpl');
-
- /*assign a value to a template variable.*\
- /*In this example {NAME} will be replaced with "XiTemplate"*/
- $xitpl->assign('NAME', 'XiTemplate');
-
- /*multidimensional array*/
- $myArray = array
- (
- 'name' => 'Jim',
- 'lastName' => 'Grill',
- 'address' => array
- (
- 'street' => 'One XiTemplate Way',
- 'city' => 'Paradise',
- 'state' => '', /* No state specified. This is a null value.*/
- 'zip' => '12345'
- ),
- 'age' => 'too old'
- );
-
- /*assign the array to a template variable*/
- $xitpl->assign('MYARRAY', $myArray);
-
- /*We don't want to display null values so we assign 'Unknown' instead*/
- /*This can be done at any time as long it's before the current block is parsed*/
- $xitpl->nullValue = 'Unknown';
-
- /*parse the first block*/
- $xitpl->parse('main.firstperson');
-
- /*null values will be ok from this point so we reset it to ''.*/
- /*This can be done at anytime before the next block is parsed so we*/
- /*could have done it on line 60 if we wanted to.*/
- $xitpl->nullValue = '';
-
- /*multidimensional array*/
- $myArray = array
- (
- 'name' => 'Travis',
- 'lastName' => 'Miller',
- 'address' => array
- (
- 'street' => 'One Coder\'s Way',
- 'city' => 'Linux Valley',
- 'state' => '', /* No state specified. This is a null value.*/
- 'zip' => '54321'
- ),
- 'age' => 'too young'
- );
-
- /*assign the array to a template variable*/
- $xitpl->assign('MYARRAY', $myArray);
-
-
- /*parse the second block*/
- $xitpl->parse('main.secondperson');
-
- /*parse the "main" block of the page (the whole page)*/
- $xitpl->parse('main');
-
- /*send the final page out to the browser*/
- $xitpl->out('main');
- ?>