I want to take output from a template that is parsed and write it to a file instead of posting it to the screen. I tried
<?php
$t = new Template("/home/mydir/mytemplates/");
// These three lines are the same as the first example:
$t->set_file("MyFileHandle","MyTemplate.ihtml");
$t->set_var("some_color",$my_color);
$t->parse("MyOutput","MyFileHandle");
// (Note that we don't call p()
//here, so nothing gets output yet.)
// Now parse a second template:
$t->set_file("WholeHandle","wholePage.ihtml");
// wholePage.ihtml has "{MyOutput}" in it
$t->parse("MyFinalOutput","WholeHandle");
// All {MyOutput}'s get replaced
//$t->p("MyFinalOutput"); //to output to a browser
// output the value of MyFinalOutput to a file
$file = $t->p('MyFinalOutput');
$fp = fopen("content/temp.ihtml", "w");
fwrite($fp,$file );
?>
But that didn't work. Nothing is in $file, and the Content still gets posted to the screen. Any ideas?
Can anyone help?
Reference to template article
http://www.phpbuilder.com/columns/david20000512.php3?page=3