I don't think you're getting my point.
I already use a template system (Xtemplate), and I have already made a template file.
Now, I want to replace the {CONTENT} field from my template by some text and images/tables etc.
But without making a huge template file, and without using HTML code inside my PHP.
Here's my index.php made as a testing version (using templates AND functions):
<?
include("$DOCUMENT_ROOT/functions.php");
include("$DOCUMENT_ROOT/header2.php");
require"$DOCUMENT_ROOT/templates/xtpl.p";
/////////////////////
// CONNECT WITH DB //
/////////////////////
connectdb();
/////////////////////
// BUILD HEADLINES //
/////////////////////
$xtpl=new XTemplate ("$DOCUMENT_ROOT/templates/tables.xtpl");
$oudedate=time()-604800;
$oudedate=date("Y-m-d h:i:s",$oudedate);
$result=mysql_query("SELECT * FROM news WHERE date>'$oudedate' ORDER BY date DESC");
if(mysql_num_rows($result)!="") {
while($row=mysql_fetch_array($result)) {
$title="$row[title]";
$id="$row[news_id]";
$exp=explode(" ",$row[date]);
$dagen=explode("-",$exp[0]);
$dag=$dagen[2];
$maand=$dagen[1];
$jaar=$dagen[0];
$datum=date ("F j", mktime (0,0,0,$maand,$dag,$jaar));
if($datum!="$nieuwedag") {
if($nieuwedag!="") {
$content.=showbr();
}
$content.=builddate($datum);
}
$content.=showbr();
$content.=buildmouseoverlink("readnews.php?id=$id","$title");
$nieuwedag="$datum";
}
} else {
$content.="No news in the database";
}
$link=buildlink("http://www.game-trix.com/articles/showarticle.php?art_id=6","here");
$image=buildimage("http://www.game-trix.com/screens/ninprevday/splash.jpg","100","115");
$image=buildlink("http://www.game-trix.com/articles/showarticle.php?art_id=6","$image");
//////////////////
// ARTICLE BLOK //
//////////////////
$xtpl->assign("REVIMAGE","$image");
$xtpl->assign("REVTITLE","Nintendo Preview Day");
$xtpl->assign("REVCONTENT","On the 31st of July we went to see all the new Gamecube and GBA games at the Nintendo Preview Day. Read about our experiences with Nintendo's upcoming games $link.");
$xtpl->parse("standardtable.reviewtable");
///////////////
// HEADLINES //
///////////////
$xtpl->assign("TITLE","HEADLINES");
$xtpl->assign("CONTENT","$content");
$xtpl->parse("standardtable");
$xtpl->out("standardtable");
/////////////////////
// EINDE HEADLINES //
/////////////////////
///////////////////////////
// PLAATJE REVIEW BOUWEN //
///////////////////////////
$xtpl=new XTemplate ("$DOCUMENT_ROOT/templates/tables.xtpl");
$revtitle=align("left","NEWEST REVIEWS");
$sql=mysql_query("SELECT * FROM reviews WHERE status='1' ORDER BY date DESC LIMIT 1")
or die(mysql_error());
if (mysql_num_rows($sql)!="0") {
$row=mysql_fetch_array($sql);
$review=align(center,$row[title]);
$review.=showbr();
$image=buildimage("$row[url]","100","140");
$image=buildlink("http://www.game-trix.com/reviews/showrev.php?rev_id=$row[rev_id]","$image");
$review.=align(center,$image);
$review.=$row[intro];
$review.=showbr();
$review.=showbr();
$link=buildmouseoverlink("http://www.game-trix.com/reviews/showrev.php?rev_id=$row[rev_id]","Read More...");
$review.=align(right,$link);
$review.=showbr();
}
/////////////////////////
// REVIEW LINKS BOUWEN //
/////////////////////////
$sql=mysql_query("SELECT * FROM reviews WHERE status='1' ORDER BY date DESC LIMIT 1,5")
or die(mysql_error());
if (mysql_num_rows($sql)!="0") {
$review.=buildnoclassimage("http://www.game-trix.com/images/$color/divider.jpg","124","4");
$review.=showbr();
while ($row=mysql_fetch_array($sql)) {
$review.=buildmouseoverlink("http://www.game-trix.com/reviews/showrev.php?rev_id=$row[rev_id]","$row[title]");
$review.=showbr();
}
}
////////////////////////////
// PLAATJE PREVIEW BOUWEN //
////////////////////////////
$prevtitle=align("right","NEWEST PREVIEWS");
$sql=mysql_query("SELECT * FROM previews WHERE status='1' ORDER BY date DESC LIMIT 1")
or die(mysql_error());
if (mysql_num_rows($sql)!="0") {
$row=mysql_fetch_array($sql);
$preview=align(center,$row[title]);
$preview.=showbr();
$image=buildimage("$row[url]","100","140");
$image=buildlink("http://www.game-trix.com/previews/showprev.php?prev_id=$row[prev_id]","$image");
$preview.=align(center,$image);
$preview.=$row[intro];
$preview.=showbr();
$preview.=showbr();
$link=buildmouseoverlink("http://www.game-trix.com/previews/showprev.php?prev_id=$row[prev_id]","Read More...");
$preview.=align(right,$link);
$preview.=showbr();
}
/////////////////////////
// PREVIEW LINKS BOUWEN //
/////////////////////////
$sql=mysql_query("SELECT * FROM previews WHERE status='1' ORDER BY date DESC LIMIT 1,5")
or die(mysql_error());
if (mysql_num_rows($sql)!="0") {
$preview.=buildnoclassimage("http://www.game-trix.com/images/$color/divider.jpg","124","4");
$preview.=showbr();
while ($row=mysql_fetch_array($sql)) {
$preview.=buildmouseoverlink("http://www.game-trix.com/previews/showprev.php?prev_id=$row[prev_id]","$row[title]");
$preview.=showbr();
}
}
// REVIEW PARSEN
$xtpl->assign("TITLE","$revtitle");
$xtpl->assign("CONTENT","$review");
$xtpl->parse("doubletable.smalltableleft");
// TUSSENTABEL PARSEN
$xtpl->parse("doubletable.dividertable");
// PREVIEW PARSEN
$xtpl->assign("TITLE","$prevtitle");
$xtpl->assign("CONTENT","$preview");
$xtpl->parse("doubletable.smalltableright");
// OUTPUT MAKEN
$xtpl->parse("doubletable");
$xtpl->out("doubletable");
/////////////////////////
// CHEATS EN DOWNLOADS //
/////////////////////////
$xtpl=new XTemplate ("$DOCUMENT_ROOT/templates/tables.xtpl");
$cheatstitle=align("right","NEWEST CHEATS");
$sql=mysql_query("SELECT * FROM cheats ORDER BY date DESC LIMIT 10")
or die(mysql_error());
if (mysql_num_rows($sql)!="0") {
while ($row=mysql_fetch_array($sql)) {
$cheats.=buildmouseoverlink("http://www.game-trix.com/cheats/showcheat.php?cheat_id=$row[cheat_id]","$row[title]");
$cheats.=showbr();
}
}
$downloadtitle=align("right","NEWEST DOWNLOADS");
$sql=mysql_query("SELECT * FROM downloads ORDER BY date DESC LIMIT 10")
or die(mysql_error());
if (mysql_num_rows($sql)!="0") {
while ($row=mysql_fetch_array($sql)) {
$downloads.=buildmouseoverlink("http://www.game-trix.com/downloads/showdown.php?down_id=$row[down_id]","$row[title]");
$downloads.=showbr();
}
}
// CHEATS PARSEN
$xtpl->assign("TITLE","$cheatstitle");
$xtpl->assign("CONTENT","$cheats");
$xtpl->parse("doubletable.smalltableleft");
// TUSSENTABEL PARSEN
$xtpl->parse("doubletable.dividertable");
// DOWNLOADS PARSEN
$xtpl->assign("TITLE","$downloadtitle");
$xtpl->assign("CONTENT","$downloads");
$xtpl->parse("doubletable.smalltableright");
// OUTPUT MAKEN
$xtpl->parse("doubletable");
$xtpl->out("doubletable");
include("$DOCUMENT_ROOT/footer2.php");
?>
Is this a correct way to do it or should it be something else? (I even put a <br> in a function).