Template file: authors.tpl
    <tr><td colspan="2">{NUM_AUTHORS}</td></tr>
<!-- BEGIN authorline -->
<!-- END authorline -->
PHP code: authors.php
//we want to display this author list
$authors = array(
'Author 1'  => 'author1@php.net',
'Author 2'  => 'author2@yahoo.com'
//load file
$tpl->setFile('tpl_authors', 'authors.tpl');
//set block
$tpl->setBlock('tpl_authors', 'authorline', 'authorline_block');
//set some variables
$tpl->setVar('NUM_AUTHORS', count($authors));
$tpl->setVar('PAGE_TITLE', 'Code authors as of ' . date('Y-m-d'));
//display the authors
foreach ($authors as $name => $email) {
$tpl->setVar('AUTHOR_NAME', $name);
$tpl->setVar('AUTHOR_EMAIL', $email);
$tpl->parse('authorline_block', 'authorline', true);
// parse and print the output
$tpl->pparse('OUTPUT', 'tpl_authors');

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>