000
03.02.2002, 18:27
Megge
|
da ich templates sehr prakitsch fände für meine page, hab ich mir den code von thw zusammengestiefelt. alles geht prima. Jetzt will ich jedoch templates in ne while schleife einbinden. (in der test.php) doch es will nicht so recht.
[b]test.php[/b] <? include("templates.head.php"); [color="#ff0000"]// die ist weiter unten noch aufgeführt[/color] include("config.head.php"); [color="#ff0000"]// darin werden sachen wie connect zum host oder style angaben gemacht[/color] $query = mysql_query("SELECT * FROM news order by news_id DESC "); while ($newspost = mysql_fetch_array($query)) { $bframe=new Template("templates/test1.html"); eval($aframe->GetTemplate()); } $aframe=new Template("templates/frame.html"); eval($bframe->GetTemplate("CONTENT")); ?>
[b]templates.head.php[/b] <? class Template { function Template($szTemplateName) { if( !file_exists($szTemplateName) ) { $this->Halt("unable to load template file: '" . $szTemplateName . "' does not exist."); } $this->szTemplateData = @implode('', (@file($szTemplateName))); $this->szTemplateData = str_replace('"', '"', $this->szTemplateData); }
function GetTemplate($szVarname = "") { if( $szVarname ) { return ('$' . $szVarname . ' .= "' . $this->szTemplateData . '";'); } else { return ('echo "' . $this->szTemplateData . '";'); } }
function Halt($szErrorMsg) { echo "<pre>MagicTemplate reported an error:\n " . $szErrorMsg . "</pre>"; exit; } } ?> [color="#ff0000"]// diese datei ist fehlerfrei - sie geht sonst immer (ist ausm thwboard code[/color]
[b]frame.html[/b] <html> <head> <LINK REL="stylesheet" HREF="style.css" TYPE="text/css"> <title> Welcome to the Newssystem </title> </head> <body bgcolor="#$config_body_bgcolor"><br> <table border=0 cellpadding=0 cellspacing=0 width=100%> <tr><td width=100% border=0 align=center>
<table border=0 cellpadding=0 cellspacing=0> <tr> <td border=0 valign=top>
$CONTENT [color="#ff0000"]// hier sollte dann "test1.html" mehrmals durch die while schleife eingeführt werden[/color]
<br><br></td></tr></table> </td></tr></table> </html> </body> [color="#ff0000"]// diese datei ist eigentlich auch fehlerfrei, prinzip wurde auch vom thwboard code // genommen und ging schon früher (einfach ohne while schleife)[/color]
[b]test1.html[/b] <table border=$config_table_border cellpadding=0 cellspacing=0 width=print $config_table_width bordercolor=#$config_table_bordercolor> <tr> <td width=$config_table_width bgcolor=$config_table_top_bgcolor height=$config_table_top_height valign=top> <b><font color=#$config_font_color_top size=$config_font_size_top> $newspost['news_title'] </font> </b> </td> </tr> <tr> <td width=$config_table_width bgcolor=$config_table_mid_bgcolor height=40> <table border=0 cellpadding=0 cellspacing=0 width=*><tr><td width=10></td><td width=*> $newspost['news_content'] </td></tr></table></td> </tr> <tr> <td width=$config_table_width bgcolor=#$config_table_bottom_bgcolor height=$config_table_bottom_height align=right class="sig"> <table border=0 cellpadding=0 cellspacing=0 width=*><tr><td width=* class=sig> <small> Posted on $newspost['news_date'], $newspost['news_time'] by <b>$newspost['news_poster']</b> </small> </td></td><td width=10></td></tr></table> </td></tr></table> [color="#ff0000"]// diese datei ist ebenfalls fehlerfrei[/color]
das was dabei rauskommt:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in e:\server\www\news\test.php(9) : eval()'d code on line 5
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in e:\server\www\news\test.php(9) : eval()'d code on line 5
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in e:\server\www\news\test.php(9) : eval()'d code on line 5
ich hab keinen blassen schimmer, was da der fehler ist
--
Dieser Beitrag wurde am 03.02.2002 um 18:35 von Megge bearbeitet.
|
|
Profil || Suche
|
001
03.02.2002, 22:12
Morpheus
|
in den Templates selber darfst du array elemente nur ohne ' ansprechen
dh
$array[element]
nicht
$array['element']
--
MFG Morpheus www.slware.com || www.thwboard.de || www.comparium.de - Der clevere Preisvergleich // Coming soon
|
|
Profil || Suche
|
002
03.02.2002, 22:53
Megge
|
juchuuu :) tag gerettet
vielen dank.
aber könnte man die 's nicht mit str_replace replacen ? so wie es mit den " gemacht wurde ? (im thwb code) weiss zwar nicht, was es bringt, aber ist bestimmt nützlich =)
--
|
|
Profil || Suche
|