Re: HTML/Template_ITX : blocks shown even if not declared.
| From: | Nicola Delbono | Date: | Sun, 11 Jan 2004 12:22:25 +0000 |
| Subject: | Re: HTML/Template_ITX : blocks shown even if not declared. | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-10105@lists.php.net to get a copy of this message | ||
On 11/01/2004 at 11.54 Joerg Bruckmann wrote:
>you set a currentBlock which is not in your template: 'maidisp'.
Thank you and sorry: all variable and block names are correct in the real script.
The one in my last mail was a fake one. The following is correct:
<?php
/* this is the php file */
include_once 'HTML/Template/ITX.php';
$tpl =& new HTML_Template_ITX('./tpl');
$tpl->loadTemplateFile('maildetail.html', TRUE, TRUE);
if(isset($_GET['display']) && $_GET['display'] == 1) {
$tpl->setCurrentBlock('mail_detail');
$tpl->setVariable(array(
'mailfrom'=>$mdata['mailfrom'],
'subject'=> $mdata['mailsubj'],
'body'=> $mdata['mailbody']
));
$tpl->parseCurrentBlock();
} else {
$tpl->setCurrentBlock('no_detail');
$tpl->parseCurrentBlock();
}
$tpl->setVariable('username', $username);
$tpl->show();
?>
I found 2 solutions but none of them satisfy me
1. use different {variable} names for the same variable.
but this is really stupid
2. addblockFile() and read an external template .
But this is an unnecessary filesystem overhead for just 2 lines of html code.