IntegratedTemlate problem
| From: | (Ed V. Bartosh) | Date: | Mon, 14 May 2001 13:10:26 +0000 |
| Subject: | IntegratedTemlate problem | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-139@lists.php.net to get a copy of this message | ||
Hi, PEAR users and developers !
I tried to use IT class with this template:
------ begin test.tpl --------------
<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>
<center>Test !</center><br>
<center>Common variable: {COMMON_VAR}</center><br>
<!-- BEGIN block1 -->
Here is variable within block1: {BLOCKVAR}<BR>
Here is common variable: {COMMON_VAR}<BR>
<!-- END block1 -->
<!-- BEGIN block2 -->
Here is variable within block2: {BLOCKVAR}<BR>
Here is common variable: {COMMON_VAR}<BR>
<!-- END block2 -->
</BODY>
</HTML>
-------end test.tpl ----------------
I want to show block1 or block2 depend of some condition and
always show rest (common part of template). How can I do that ?
I tried to do that this way:
<?php
require_once("HTML/IT.php");
$tpl = new IntegratedTemplate("./templates");
$tpl->loadTemplatefile("test.tpl", TRUE, TRUE);
$tpl->setVariable("COMMON_VAR","This variable is needed within common part, block1
and block2");
if (isset($HTTP_GET_VARS['condition'])) {
$tpl->setVariable("BLOCKVAR","block1 variable");
$tpl->parse("block1");
} else {
$tpl->setVariable("BLOCKVAR","block2 variable");
$tpl->parse("block2");
}
$tpl->parse();
$tpl->show();
?>
But it doesn't work as I expect.
Here is the output of this script :
--------------
Test !
Common variable:
Here is variable within block2: block2 variable
Here is common variable: This variable is needed within common part, block1 and block2
--------------
As you can see, it doesn't show common part variable outside the blocks.
What did I do wrong ?
Answer, please.
Thank you in advance.
--
Best regards, Ed