Forum Moderators: coopster

Message Too Old, No Replies

phplib template issues

         

hutchic

8:22 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



I developed a small CMS on a Windows machine running apache/mysql. Upload it to my webhost *nix and all's working fine untill a few days ago, I've also found other hosts have the same problem:

The problem (simplified) is using the phplib template library any var's a set in a function don't make it back to the calling function (anymore).

index.html


<html>
<body>
{value}
</body>
</html>

doesn't work:


include_once('template.inc');
$t = new Template(template_dir,"keep");
$t->set_file("mainpage","index.html");
footer($t);
$t->pparse("OUT", "mainpage");

function footer($t){
$t->set_var("value","blah");
}

works:


include_once('template.inc');
$t = new Template(template_dir,"keep");
$t->set_file("mainpage","index.html");
$t->set_var("value","blah");
$t->pparse("OUT", "mainpage");

hutchic

12:03 am on Jan 26, 2006 (gmt 0)

10+ Year Member



resolved:


include_once('template.inc');
global $t;
$t = new Template(template_dir,"keep");
$t->set_file("mainpage","index.html");
footer($t);
$t->pparse("OUT", "mainpage");

function footer($t){
global $t;
$t->set_var("value","blah");
}

coopster

12:21 am on Jan 26, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Oh, so this entire code snippet is part of a function? I didn't realize that, but I guess you didn't specify that either. I thought you meant the $t variable couldn't be passed to the footer function.

hutchic

2:20 am on Jan 26, 2006 (gmt 0)

10+ Year Member



it could be passed but it the updated values in function footer don't make it back to be parsed and output (pparse)

They used to but just stopped recently... but it's fixed now so water under the bridge ;)