Hello
I am trying to do something very simple with phplib templates. This is to functionise a header output and a footer output. Rather than doing the clumsy and tiring way of putting in code on every page you need a template inputted, like so
include("template.inc");
$t = new Template('.', "keep");
$t->set_file('page', "template.ihtml");
$t->set_var('TITLE', "foo.");
$t->set_block('page', 'header');
$t->pparse('out', 'header');
{BODY}
$t->set_block('page', 'footer');
$t->pparse('out', 'footer');
I decided to make 2 functions for easier coding.
1st being:
function htmlHeader()
{
checkLogin();
include("template.inc");
$t = new Template('.', "keep");
$t->set_file('page', "template.ihtml");
$t->set_var('TITLE', "foo");
$t->set_var('JS', " onload=\"disp_alert();change_Location()\"");
$t->set_block('page', 'header');
$t->pparse('out', 'header');
}
and 2nd being
function htmlFooter()
{
mysql_close(dbConnect() );
$t->set_block('page', 'footer');
$t->pparse('out', 'footer');
}
the 1st function included on a page goes fine and outputs the correct templated header. But when I try to finish the page off with my footer function.... booom
[Mon Jun 05 08:20:12 2006] [error] [client 127.0.0.1] PHP Notice: Undefined variable: t in D:\\inetpub\\www\\timesheets\\core\\main_api.php on line 73, referer: http://localhost/timesheets/
[Mon Jun 05 08:20:12 2006] [error] [client 127.0.0.1] PHP Fatal error: Call to a member function set_block() on a non-object in D:\\inetpub\\www\\timesheets\\core\\main_api.php on line 73, referer: http://localhost/timesheets/
and my page does not finish.
Can please someone tell me firstly, am I attempting to do the right thing and secondly how can I make this work.
Thank you for your time.