This post refers to DotKernel 1, based on Zend Framework 1.
If you are looking for DotKernel 3 related posts, go here.

Template file: authors.tpl
<html>
 <head><title>{PAGE_TITLE}</title></head>
 <body>
  <table>
   <caption>Authors</caption>
   <thead>
    <tr><th>Name</th><th>Email</th></tr>
   </thead>
   <tfoot>
    <tr><td colspan="2">{NUM_AUTHORS}</td></tr>
   </tfoot>
   <tbody>
<!-- BEGIN authorline -->
    <tr><td>{AUTHOR_NAME}</td><td>{AUTHOR_EMAIL}</td></tr>
<!-- END authorline -->
   </tbody>
  </table>
 </body>
</html>
PHP code: authors.php
<?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>