Simple example

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

 {PAGE_TITLE}
 
  
Authors
NameEmail
{NUM_AUTHORS}
{AUTHOR_NAME}{AUTHOR_EMAIL}
PHP code: authors.php
 '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>