newbie: IT[X] setTemplate vs. loadTemplatefile ?
| From: | marion schmid | Date: | Thu, 23 Aug 2001 14:12:30 +0000 |
| Subject: | newbie: IT[X] setTemplate vs. loadTemplatefile ? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-286@lists.php.net to get a copy of this message | ||
Hi all!
I just decided to use IT respectively IT[X] as Template system and I am
currently doing some tests with blocks.
I found a documentation of Ulf Wendel at
http://www.phpbuilder.com/mail/phplib-dev-list/2000092/0005.php
where it says to use setTemplate(); instead of LoadTemplatefile(); when
using ITX.
I wrote following example and had permanently problems with
setTemplate(); (pop-up "document contained no data")
until I tried out to use LoadTemplatefile(); instead of setTemplate();
and it worked.
What I am wondering: what attributes do I have to write for string
template in
$tpl->setTemplate(string Template [,boolean removeUnknown ....]); if not
the filename of the template, what
I use with LoadTemplatefile(); ? Maybe that was my mistake?
thanks,
marion
--
Blocks with IT[X] (version that works - with loadTemplatefile)
--
<?php
include_once ("HTML/ITX.php");
$tpl = new IntegratedTemplateExtension("templates/");
$tpl->loadTemplatefile("index.tpl.html");
//my block
$tpl->addBlockfile("test","meinBlock","block.tpl.html");
$tpl->setCurrentBlock("meinBlock");
for($i=1; $i<4;++$i){
$tpl->setVariable(array("id"=>$i));
$tpl->parseCurrentBlock();
}
$tpl->setVariable("TITLE","das ist ein Test");
$tpl->setVariable("CONTENT","Das hier ist der Content");
$tpl->show();
?>
--
Blocks with IT[X] (version that didn't work because of setTemplate();)
---
<?php
include_once ("HTML/ITX.php");
$tpl = new IntegratedTemplateExtension("templates/");
$tpl->setTemplate("index.tpl.html");
//my block
$tpl->addBlockfile("test","meinBlock","block.tpl.html");
$tpl->setCurrentBlock("meinBlock");
for($i=1; $i<4;++$i){
$tpl->setVariable(array("id"=>$i));
$tpl->parseCurrentBlock();
}
$tpl->setVariable("TITLE","das ist ein Test");
$tpl->setVariable("CONTENT","Das hier ist der Content");
$tpl->show();
?>
-----------
my templates look like this:
--
#index.tpl.html#
<html><head><title>{TITLE}</title></head>
<body>
my Title: {TITLE}<br>
{CONTENT}<br>
block begins:<br>----<br>
{test}
<br>----<br>block ends
</body>
</html>
--
#block.tpl.html#
<!--BEGIN meinBlock-->
das ist die id: {id}<br>
<!--END meinBlock-->
--