Hi,
ich hab nen template system geschrieben...
global.php:
index.php:
tpl.class.php:
templates/index.php:
templates/header.php:
so in templates/index.php gibt es ja sowas wie $PageName/$header wie repace ich das am besten? bei $PageName will ich einfach von der DB den namen raus suchen(is kein problem) und bei $header will ich NOCHMAL eine datei inlcuden(templates/header.php) wie mache ich das ambesten?
hoffe ihr könnt mir dabei helfen
Mit freundlichen Grüßen
BlueFox
ich hab nen template system geschrieben...
global.php:
PHP:
<?php
require "inc/sql.php";
require "inc/mysql.class.php";
require "inc/tpl.class.php";
$MySQL = new MySQL();
$tpl = new tpl();
?>
index.php:
PHP:
<?php
require "global.php";
$tpl->output($tpl->get("index"));
?>
tpl.class.php:
PHP:
<?php
class tpl {
var $templates = array();
var $path = ".";
function get($tplName) {
if(!$this->templates[$tplName]) {
if(file_exists($this->path."/templates/".$tplName.".php")) {
include $this->path."/templates/".$tplName.".php";
} else {
return $this->tempaltes[$tplName] = 'Template "'.$tplName.'" ist nicht vorhanden!';
}
}
return $this->templates[$tplName];
}
function output($template) {
print $template;
}
}
?>
templates/index.php:
PHP:
<?php
$this->templates['index'] =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
$header
<title>$PageName</title>
</head>
<body>
!!!FUNKTIONIERT!!!
</body>
</html>';
?>
templates/header.php:
PHP:
<?php
$this->templates['header'] =
'HEEEDEER :D';
?>
so in templates/index.php gibt es ja sowas wie $PageName/$header wie repace ich das am besten? bei $PageName will ich einfach von der DB den namen raus suchen(is kein problem) und bei $header will ich NOCHMAL eine datei inlcuden(templates/header.php) wie mache ich das ambesten?
hoffe ihr könnt mir dabei helfen
Mit freundlichen Grüßen
BlueFox