Documentation for SKOR PHP Template


  • A webserver e.g.  Apache and PHP 5
  • PHP support for output buffering  (Output Buffering)
  • Skor template class
  • Skor section class (optional)


Download the classes here: unpack them  and put the files into your include directory.

Change the ownership and rights of the files the way it suits your requirements.

First steps

Create a textfile with the following content and save it as "template.tpl".

<h1>I call out: {UNIVERSE}</h1>

The "{UNIVERSE}" will be your placeholder for later replacement.

Now .create another file called test.php.

$tpl = new template();
$tpl ->dir = '';
$tpl->html = 'template.tpl';
$tpl->assign('UNIVERSE', 'Hallo World');

The "$tpl->dir" should point to the directory where you saved the template.tpl file in.
It must have a trailing slash ( / ),

"$tpl->html" already points to your template file. Of course it must be readable.

"$tpl->read()" will parse the template file now.

finally "$tpl->assign()" will do the replacement and "$tpl->display()" will show you the result.


The following is a somewhat more complex example to be used with class section:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" lang="{LANG}" xml:lang="{LANG}">
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
<style type="text/css">
body {font-family: Arial, sans-serif; font-size:100.01%}
table.noborder {border:none; border-collapse:collapse;}
table.noborder tr.row_even td {background-color:#DDD; border-top: 1px solid #999; border-bottom: 1px solid #999;}
table.noborder td {padding:2px 10px 2px 3px;}
table.noborder td.first {font-weight:bold;}

<table class="noborder">

<tr class="row_{ODD}">
<td class="first">{POSITION}</td><td>{VORNAME} {NAME}</td><td>{TEL}</td>


And the PHP-part:


$data = array ();
$data[] = array('vorname'=>'Franz','name'=>'Gumper','position'=>'Vorstand', 'tel'=>'05511 123 456-789');
$data[] = array('vorname'=>'Georg','name'=>'Bumpel','position'=>'Vorstand', 'tel'=>'03311 123 456-789');
$data[] = array('vorname'=>'Hans','name'=>'Hauer','position'=>'Vorstand', 'tel'=>'01155 123 456-789');

$tpl = new section();
$tpl ->dir = '';
$tpl->html = 'section.tpl';
$tpl->assign('LANG', 'de');
$tpl->assign('CHARSET', 'iso-8859-1');
$tpl->assign('TITLE', 'Test site: Section Test');
$tpl->assign('HEADER', 'Section Test');
$tpl->assign('INTRO', 'Just a little intro text ...');
$tmp = '';
for ( $i = 0; $i<sizeof($data); $i++) {
        $tpl->assign('POSITION', $data[$i]['position']);
        $tpl->assign('VORNAME', $data[$i]['vorname']);
        $tpl->assign('NAME', $data[$i]['name']);
        $tpl->assign('TEL', $data[$i]['tel']);
        $tpl->assign('ODD', (($i+1) % 2) ? 'odd' : 'even' );
        $tmp .= $tpl->fetch('TABLE_ROW');

$tpl->assign('S_TABLE_ROW', $tmp);
$tpl->assign('S_TABLE', $tpl->fetch('TABLE'));