Re: PEAR Integrated Template Class
| From: | Andre Gildemeister | Date: | Sun, 22 Jul 2001 10:35:29 +0000 |
| Subject: | Re: PEAR Integrated Template Class | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-217@lists.php.net to get a copy of this message | ||
> Sorry but i don't really understand german.
> I'm totally clueless on where to start
> using the IT class. Can someone help
> shed light to me on this.
>
> I would appreciate some sample codes.
Okay one example!
You have the following html template:
* * * * * * * * * * * *
<table border>
<tr>
<td>{PLACEHOLDER}</td>
</tr>
<!-- BEGIN block -->
<tr>
<td>{FOO}</td>
</tr>
<!-- END block -->
</table>
* * * * * * * * * * * * *
$tpl = new IntegratedTemplate([string filerootdir]);
$tpl->loadTemplatefile( string filename [, boolean removeUnknownVariables,
boolean removeEmptyBlocks] )
To add content to PLACEHOLDER you simply type:
* $tpl->setVariable("PLACEHOLDER,"CONTENT");
After parsing, the placeholder replace by the CONTENT.
When you want to use the Block API, you must proceed as follows:
To add content to "block" you would type something like:
$foo = array();
$foo[0] = "test";
$foo[1] = "bar";
$foo[2] = "hello";
for($i=0; $i<count($foo); $i++) {
$tpl->setCurrentBlock("block");
$tpl->setVariable("FOO",$foo[$i]);
$tpl->parseCurrentBlock();
}
At last you print out the template with: $tpl->show()
The inline soure documentation of the Integrated Template is very usefull,
please look at:
http://www.ulf-wendel.de/docs/itx/index2.html
best regards
Andre Gildemeister