On 2/1/02 10:28 AM, "Peter Holm" <PH...@gm...> wrote:
> If you have a block, in which there are no {VARS} replaced, the whole
> block is shown in the output.
<code>
// Create your template object
$tpl = new Template('/my/template/dir/','remove');
// Read in your template file
$tpl->set_file(array("page" => "item.html"));
// Call set_block, replacing the block with a variable
$tpl->set_block("page","my_block","output");
// If there is data, sel the varibles in the block and parse
if ($data) {
while ($data) {
$tpl->set_var(array(
"var1" => $var1;
// etc
));
// Call parse appending to any other rows/blocks already output
$tpl->parse("output","my_block",true);
}
} else {
// No data so strip the block
$tpl->set_var("output","");
}
</code>
If the template object is created and told to remove undefined variables,
the else statement should not be necessary, but for some reason I think it
is...
|