Template Funktion ich verzweifle noch!!!!!
Verfasst: 05.06.2004 00:24
Ich krieg ne Asche ich sitze nun seit fast einer Woche vor dem Problem.
Hab schon in unzähligen Foren um rat gefragt.
Ich bekomme einfach nicht zustande das die Templates richtig geparst werden.
index.php:
index.tpl:
class_template.php:
Warum wird der php code nicht ausgeführt und statt dessen nur so angezeigt wie er in der index.php steht?
Ich hab auch schon eval() ausprobiert nix führt zum erfolg
Hab schon in unzähligen Foren um rat gefragt.
Ich bekomme einfach nicht zustande das die Templates richtig geparst werden.
index.php:
Code: Alles auswählen
<?
$tmpl_name = 'index.tpl';
$tmpl_content[title] = 'echo "blabla";
$gaga = 123 + 123;
echo $gaga;';
$tmpl_content[text] = 'echo "Hallo Welt";
$baba = 999 * 999;
echo $baba;';
require_once('./templates/class_template.php');
template ($tmpl_name, $tmpl_content);
echo $work;
?>
Code: Alles auswählen
<html>
<head>
<title>%%title%%</title>
</head>
<body><center>%%text%%</center>
</body>
</html>
Code: Alles auswählen
<?
function template ($tmpl_name, $tmpl_content) {
$dir = 'c:\\intranet\\Apache2\\htdocs\\test\\templates';
global $work;
$pfad = "".$dir."\\".$tmpl_name."";
$tmpl = file_get_contents($pfad);
if ( trim($tmpl) != "" ) {
$work = $tmpl;
while ( list( $key, $val ) = each( $tmpl_content ) ) {
$x = "%%" . strtolower($key) . "%%";
$work = str_replace($x, "<?".$val."?>", $work);
}
}
return $work;
}
?>
Ich hab auch schon eval() ausprobiert nix führt zum erfolg
