Jump to content

PEAR HTML_TEMPLATE_ITX only parses a block if you set a variable?????


woozy

Recommended Posts

After much struggling where !!!none!!! of my blocks were being parsed, I finally discovered they were parsed if I set a variable.


For example:
I had a template file called "foo.tmp" consisting of:

<html><body>Hello<br>
{PAGE_BODY}
</body></html>


A template scrap file called "goo.tmp" consisting of:
<h1>HELLO</h1>

and the php file consisting of

<?php
require_once "HTML/TEMPLATE/ITX.php";

$template = new HTML_TEMPLATE_ITX(".");
$template->loadTemplatefile("foo.tmp");
$template->addBlockFile("PAGE_BODY", "pageBody", "goo.tmp");
$template->setCurrentBlock("pageBody");
$template->parseCurrentBlock();
$template->show();
?>

The page would utterly blank and no error would be registered in the server log.

BUT  if I edited the php script to have...

...
$template->setCurrentBlock("pageBody");
$template->setVariable("GLOM", "whatever");
$template->parseCurrentBlock();
....

THEN the page would render.

So... you can't just parse a block without setting a variable?????  Any way around this?

Okay figured it out.

Use

$template->touchBlock("pageBody");


to display the block but don't replace variables.  Gets a bit complicated though.  If you touch it, you don't want to parse it later or it gets outputted twice.  I think this is Okay.  I think if you replace a variable but not parse but touch the block later it comes out the same...  I hope.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.