Re: Re[2]: [PEAR-DEV] a question to HTML_Template_IT/ITX maintainers
| From: | Adam Morton | Date: | Thu, 19 Sep 2002 15:38:21 +0000 |
| Subject: | Re: Re[2]: [PEAR-DEV] a question to HTML_Template_IT/ITX maintainers | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-9213@lists.php.net to get a copy of this message | ||
> Well, I introduced the setGlobalVariable() method. Variables set by
> it are substituted into every block and do not trigger the
> "block empty/nonempty" logic. Great for common directory prefixes,
> session identifiers and
> this kind of stuff.
That sounds perfect!
> No, I didn't implement anything like this. I don't think it's
> possible with the current model, either. You either have to know
> blocks' names and explicitly call parse _or_ embed some sort of info
> on which data to get into the template itself.
I am using the following code semi-successfully and it seems to parse the
blocks in the correct order:
[code]
$template_dir = "/your/template/directory";
$template_file = "your_template.html";
$var_array = array("TITLE"=>"This is the title",
"CONTENT"=>"This is the content");
$tpl = new IntegratedTemplate($template_dir);
$tpl->loadTemplatefile($template_file);
$tpl->setVariable($var_array);
$tpl->show();
[/code]
The only time I have a problem with it is if you send in $var_array with
all values set to NULL. When you call the loadTemplatefile() or
setTemplate() function the init() function is called which pre-parses the
template and sets up the block heirarchy (findBlocks()). Then when you
call get() or show()...parse() is called which uses this info to parse
each block. That's the main thing I wanted to bring to your attention
since it makes the basic use of the IT class very easy.
Adam
---------------------------------
Adam Morton
Developer - Web Technology Group
Appalachian State University
http://phpwebsite.appstate.edu
adam@tux.appstate.edu