[PHP] Tempalteparser Klasse zeigt template nicht richtig an.

pczombie

Banned
Dabei seit
Dez. 2005
Beiträge
201
moin jungs,

ich habe hier ein großes Problem mit meiner templateparser Klasse. Alles funktioniert soweit, Pfade der Templates werden richtig übergeben und die templates sind auch richtig benannt und existieren.

Woran könnte es liegen das mir der Inhalt nicht ausgeben wird?
Der aufruf erfolgt folgendermaßen:

PHP:
<?php
    error_reporting(E_ALL);        
    require_once 'mysql.class.php';
    require_once 'Page_Builder.class.php';     
    require_once 'tpl_parser.php';
    
    $PageConfig = new Page_Builder();
    $tpl = new TPL();
    
    try
    {            
        $mysql = new DB_MySQL('localhost', 'butschi', 'root', 'ficken');    
        
        /* Erzeugen der Meta Informationen wie Title, Beschreibung und Schlüsselwörter */    
        $PageConfig->SetHead('Test OOP Seite',
                                'PHP 5 OOP, Test, OOP',
                                'Dies ist eine PHP5 OOP Testseite');        
        $mysql->query('SELECT * FROM test');
         
        while ($row = $mysql->fetchRow())
        {
            // ... Template aufruf
            eval ("\$bla = \"" . $tpl->load("test") . "\";");
            //eval ("$tpl->parse(\"" . $tpl->load("test") . "\");");
        }
    }
    catch (DB_Exception $e)
    {
        printf('Ein Datenbankfehler ist aufgetreten: %s', $e->getMessage());
    }
    catch (Exception $e)
    {
          printf('Ein allgemeiner Fehler ist aufgetreten: %s', $e->getMessage());
    }
    
   //Layout aufruf in der die Varialbe $bla steht (nur zum testen) nix besonderes
    eval ("$tpl->parse(\"" . $tpl->load("layout") . "\");");
    
    $PageConfig->SetFoot();
?>

Die Klasse hat folgende Strucktur:

PHP:
<?php
class TPL
{
    private $templatefile = NULL;    
    public $templatepath = "http://localhost/butschi/tpl/";
    public $template = NULL;
    
    private static $endung = "html";
    
    public function load($template)
    {
        $this->template = $template;
        //Absoluten Templatepfad ermitteln und in Variable $templatfile schreiben
        $this->templatefile = $_SERVER['DOCUMENT_ROOT'] . "/butschi/tpl/" . $this->template . "." . "html";            
        
        if(file_exists($this->templatefile))
        {
            echo $this->templatefile . "<br>";
            echo $this->templatepath . "<br>";
            echo $this->template . "<br>";                    
            echo "<br />";
            
            return str_replace("\"" , "\\\"" , file_get_contents($this->templatepath . $this->template . "." ."html"));            
        }
        else
        {
            print "HTML Template file <b>$templatefile</b> wurde nicht gefunden <br />";
        }
    }        
    
    public function parse($template)
    {
        $this->template = $template;
        print $this->template;
    }
}
?>

Könnt ihr mir sagen woder Hund begraben liegt?
 
Zurück
Top