Location: PHPKode > scripts > Template class > template-class/complete-script.php
<?php
/**
* o------------------------------------------------------------------------------o
* | This package is dual licensed as GPL and a commercial license.               |
* | If you use the code commercially (or if you don't want to be restricted by   |
* | the GPL license), you will need the commercial license. It's only £49 (GBP - |
* | roughly $98 depending on the exchange rate) and helps me out a lot. Thanks.  |
* o------------------------------------------------------------------------------o
*
* © Copyright Richard Heyes
*/

/***************************************
** Title........: Template Example
** Filename.....: complete-script.php
** Author.......: Richard Heyes
** Version......:
** Notes........: This shows an example of
**                using just one template file
***************************************/

        include('class.template.inc');

/***************************************
** Set a couple of example variables.
***************************************/
		$if_var		= 1;
        $test_var	= 'Hello World!';
        $page_title	= 'Template Class';

/***************************************
** Set a couple of example arrays.
***************************************/
        $table_rows = array();
        $table_rows[] = array( 'column_1' => 'This is column one on row one!',
                               'column_2' => 'This is column two on row one!',
                               'column_3' => 'This is column three on row one!'
                             );

        $table_rows[] = array( 'column_1' => 'This is column one on row two!',
                               'column_2' => 'This is column two on row two!',
                               'column_3' => 'This is column three on row two!'
                             );

/***************************************
** Postgres stuff. This was the code I
** used to test the $obj->parse_pgsql()
** method. Worked too.
***************************************/
/*
        $pg = pg_connect('user=richard dbname=scripts port=5432');

        $sqlquery = 'SELECT col1 AS column_1, col2 AS column_2, col3 AS column_3 FROM test';
        $table_rows = pg_exec($pg, $sqlquery);
*/
/***************************************
** The template goodies, using shortcut
** functions.
***************************************/
        $tpl = new template;
        $tpl->load_file('complete', 'complete-template.html');
		$tpl->parse_if('complete', 'if_var');
        $tpl->parse_loop('complete', 'table_rows');
        $tpl->pprint('complete', array('test_var','page_title', 'test_output'));

/***************************************
** The template goodies, using the
** longer method.
***************************************/
/*
        $tpl = new template;
        $tpl->load_file('complete', 'complete-template.html');
        $tpl->register('complete', 'test_var,page_title');
        $tpl->parse_loop('complete', 'table_rows');
        $tpl->parse('complete');
        $tpl->pprint('complete');
*/

?>
Return current item: Template class