I am trying to pass an object to a function in php 4.2.2. I am also using xtemplate which allows me to seperate my php code from my html code. When I parse in the main loop of the program the information parses, but when I try to parse from within a function it does not parse.
I included an attachment of the x template class that allows me to seperate my html code from my php code.
This is my script.
<?php
include '../xtemplate/xtemplate.class.php';
function xtplTest(&$xtpl)
{
$message = "test";
$xtpl->assign('message', $message);
$xtpl->rparse('main.message');
}
function xtplTest1(&$xtpl)
{
$message1 = "test1";
$xtpl->assign('message1', $message1);
$xtpl->rparse('main.message1');
}
// main
$xtpl = new XTemplate ('index.htm');
xtplTest($xtpl);
xtplTest1($xtpl);
$message2 = "test2";
$xtpl->assign('message2', $message2);
$xtpl->rparse('main.message2');
$xtpl->parse('main');
$xtpl->out('main');
?>
This is my HTML code. The comment tags allow for parsing of individual blocks.
<!-- BEGIN: main -->
<html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<!-- BEGIN: message -->
{FILE xtplTest.xtpl}
<!-- END: message -->
<!-- BEGIN: message1 -->
{FILE xtplTest.xtpl}
<!-- END: message1 -->
<!-- BEGIN: message2 -->
{message2}
<!-- END: message2 -->
</body>
</html>
<!-- END: main -->
This is my xtplTest.xtpl file.
{message}{message1)