czesc
mam problem z przerobieniem storny w HTML-u na PHP przy wykozystaniu klasy template. przy pisanu kozystalem z materialow z tej strony http://www.leon.w-wa.pl/texts/templates.php
no i tu zaczyn sie problem nie chce mi sie otwiera strona z pliku index.php tylko otwiera sie z index.html. druga sprawa to ze jak otworze index.php to mi nie podmienia zawartosci pliku.
zamieszcze kod z index.php i index.html. i bylbym wdzieczny gdyby ktos mi powiedzial ggdzie mam bledy.
index.php
class Template {
var $tmpl;
var $dane;
function Template ($name)
{
$this->tmpl = implode('', file($name));
$this->dane = Array();
}
function add($name, $value = '')
{
if (is_array($name)) {
$this->dane = array_merge($this->dane, $name);
} else if (!empty($value)) {
$this->dane[$name] = $value;
}
}
function execute() {
return ereg_replace('/{([^}]+)}/e', '$this->dane["\\1"]', $this->tmpl);
}
}
$ntemp=new Template ('index.html');
$ntemp->add('naglowek', file_get_contents('naglowek.html'));
$ntemp->add('menu', file_get_contents('menu.html'));
$ntemp->add('edytory', file_get_contents('news.html'));
$ntemp->add('stopka', file_get_contents('stopka.html'));
$url = $_GET['page'] ;
if ( isset ( $url ) )
{
if($url=='edytory')
$content = file_get_contents('news.html') ;
else if($url=='historia')
$content = file_get_contents('historia.html') ;
else if($url=='biografia')
$content = file_get_contents('biografia.html') ;
else if($url=='galeria')
$content = file_get_contents('galeria.html') ;
else if($url=='formularz')
$content = file_get_contents('formularz.html') ;
else if($url=='javascript')
$content = file_get_contents('javascript.html') ;
}
else $content = file_get_contents('news.html') ;
$ntemp->add('content', $content) ;
echo $ntemp->execute();
index.html
<html>
<head>
<title>KORN</title>
</head>
<body>
<frameset rows="10%,*,11%" bordercolor="black">
<frame noresize scrolling="no" {naglowek}>
<frameset cols="20%,*%">
<frame noresize scrolling="no" {menu}>
<frame scrolling="yes" {edytory}>
</frameset>
<frameset rows="*">
<frame noresize scrolling="no" {stopka}>
</frameset>
</frameset>
</body>
</html>