interazione database template system

felixaf21

Nuovo Utente
19 Mar 2008
13
0
0
Salve a tutti ho una classe che riesce a gestire un sistema di template solo la parte statica di un sito:

ecco la classe:



class tpl {

public $tpl;

function __construct($path){
$this->tpl = file_get_contents($path);
}
function replace($tag) {
foreach($tag as $key => $value) {
$this->tpl = str_replace("{-".$key."-}", $value, $this->tpl);
}
}


function publish() {
return $this->tpl;
}
function __destruct() {
unset($this->tpl);
}
}

Pagina html per richiamare il tpl:

<!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" />
<title>Documento senza titolo</title>
</head>

<body>
<div>{-title-} -- {-prova-}</div>
</body>
</html>


se volessi interaggire con un database ed estarre tutti i dati tramite un ciclo while questa classe non me lo permette...
come posso implementare una fuzione che mi riesce a gestire anche con un database??
grazie mille in anticipo...
 

Discussioni simili