> Hi,
>
> ok, basically I tried to put the question in the subject.
>
> If you have a block, in which there are no {VARS} replaced, the whole
> block is shown in the output.
>
> I am not a wizard, but after taking a look into template.inc it seems,
> like this behaviour can not be changed easily, am I right?
Correct. I create blocks in my templates for clearing out lists and other
bits of content that are only shown when certain criteria are met. I often
have 2 or 3 blocks in one part of the page when only 1 of them will ever be
shown at a time. To save parsing time, I do not declare the blocks I keep.
Extending upon my recent example:
***** sample.html *****
<!-- BEGIN show_employees -->
<table>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
<!-- BEGIN employee -->
<tr>
<td>{name}</td>
<td><a href="mailto:{email}">{email}</a></td>
</tr>
<!-- END employee -->
</table>
<!-- END show_employees -->
<!-- BEGIN no_employees -->
I'm sorry, no records could be found.
<!-- END no_employees -->
***** /sample.html *****
***** sample.php *****
$t = new Template;
$t2 = new Template;
$t->set_file("content", "sample.html");
$db = new DB_MySQL;
$db->query("select name, email from employee order by name");
if($db->num_rows()) {
$t->set_block("content", "employee", "employees");
$t2->set_var("employee", $t->get_var("employee"));
while($db->next_record()) {
$t2->set_var($db->Record);
$t2->parse("employees", "employee", true);
}
$t->set_var("employees", $t2->get_var("employees"));
$t->set_block("content", "no_employees");
$t->set_var("no_employees", "");
}
else {
$t->set_block("content", "show_employees");
$t->set_var("show_employees", "");
}
$t->parse("out", "content");
$t->pparse("out");
***** /sample.php *****
Layne Weathers
Ifworld Inc.
|