Location: PHPKode > scripts > XS PHP Library > xs-php-library/src/template.php
<?php
//
// +--------------------------------------------------------------------------+
// |                                                                          |
// |                   XS PHP Library  Generic Classes Library                |
// |                                                                          |
// |                   Copyright (c) 2001-2002 XSPHPLib Group.                |
// |                                                                          |
// +--------------------------------------------------------------------------+
// |                                                                          |
// | Distributed under the terms of the GNU Lesser General Public License as  |
// | published by the Free Software Foundation version 2.1                    |
// | See the GNU Lesser General Public License for more details. You should   |
// | have received a copy of the GNU Lesser General Public License along with |
// | this package; if not, write to the Free Software Foundation, Inc.,       |
// | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.                 |
// |                                                                          |
// +--------------------------------------------------------------------------+
// |                                                                          |
// | Authors: Robert Bala <hide@address.com>                                   |
// |                                                                          |
// +--------------------------------------------------------------------------+
//
// $Id: template.php,v 1.2 2002/11/28 09:51:38 rbala Exp $

include_once('../inc/object.inc.php');
include_once('../inc/template.inc.php');

$items[] = array('1', 'item A');
$items[] = array('2', 'item B');
$items[] = array('3', 'item C');
$items[] = array('4', 'item D');

$tpl = new Template('./');

$tpl->setFile('page_header', 'header.tpl');
$tpl->setFile('page_screen', 'screen.tpl');
$tpl->setFile('page_footer', 'footer.tpl');

$tpl->parseFile('page_header');
$tpl->parseFile('page_screen');
$tpl->parseFile('page_footer');

$tpl->setParam('page_title', 'Sample Page Title');

$tpl->setBlock('page_screen', 'ListItems');

for ($i = 0; $i < count($items); $i++) {
    $tpl->setParam('item_id', $items[$i][0]);
    $tpl->setParam('item_data', $items[$i][1]);
    
    $tpl->parseParam('ListItems', 'ListItemsDynamic', true);
}

$tpl->setParam('ListItems', $tpl->getParam('ListItemsDynamic'));

$tpl->setParam('date_value', date ("l dS of F Y h:i:s A"));

$tpl->setRoot('../');

$tpl->setFile('readme_file', 'README');

$tpl->parseFile('readme_file');

$tpl->setParam('readme_file', nl2br($tpl->getParam('readme_file')));

$tpl->parseParam('page_screen');
$tpl->printParam('page_screen');

?>
Return current item: XS PHP Library