Forum Moderators: coopster

Message Too Old, No Replies

PHP Templates

         

andrewsmd

6:30 pm on Feb 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use the php IT.php template file to generate HTML.

I have an html file that is something like this.
<html>
<body>
<table>

<!-- BEGIN spot1 -->
<tr><td>{someStuff}</td></tr>
<!-- END spot1 -->

<!-- BEGIN spot2 -->
<tr><td>{someOtherStuff}</td></tr>
<!-- END spot2 -->
</table>
</body>
</html>

The problem I have is when I set the templates they go where they are positioned in the HTML (obviously) but I want them to output in the order they are in PHP. What I mean is something like this
<?php

require_once("IT.php");

//load my template
$template = new HTML_Template_IT("./");

//load my html
$template->loadTemplatefile("my.tpl");

$template->setCurrentBlock("spot1");
$template->setVariable("someStuff", "this should be the first html");
$template->parseCurrentBlock();

$template->setCurrentBlock("spot2");
$template->setVariable("someOtherStuff", "this should be the second html");
$template->parseCurrentBlock();

$template->setCurrentBlock("spot1");
$template->setVariable("someStuff", "this should be the thrid html");
$template->parseCurrentBlock();

$template->show();
?>

Now my html would look something like this
this should be the first html
this should be the third html
this should be the secon html

It is like that because the way they are lined up in the template file.
Is there anyway to make them go one after the other in the order I want? Thanks,

dreamcatcher

7:53 am on Feb 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can`t you just change the variable names around in the html? Or create new variables in the html?

dc