Hallo,
ich habe mir ein kleines TPL System gebastelt doch habe ich einen Fehler drinne den ich nicht verstehe.
Hier mal der Code:
tpl.class
	
datei.php
	
tpl datei die dazu gehört:
	index.php
	
wenn ich eine Variable setze in datei.php und die tpl datei direkt include funktioniert der Code.
Aber wenn ich es über die funktion mache wird zwar normal es HTML ausgegeben aber nicht die Variable da steht dann NOTICE: Variable nicht gesetzt...
Aber warum werden die Variablen nicht übergeben wurde doch beides in die index geladen.
mfg Marco
					ich habe mir ein kleines TPL System gebastelt doch habe ich einen Fehler drinne den ich nicht verstehe.
Hier mal der Code:
tpl.class
PHP-Code:
	
	
    function set_tpl ($tpl_name, $tpl_typ = "index") {
        
        if($tpl_typ == "index") {
            $file = $this->index_path_tpl . $tpl_name . ".tpl";
            if(file_exists($file)) {
                $this->get_title();
                $this->tpl_include = $file;
            } else {
                $this->error_handler(TPL, $tpl_name . ".tpl (" . $tpl_typ . ") ist nicht vorhande!");
            }
        
        } elseif($tpl_typ == "user") {
            $file = $this->user_path_tpl . $tpl_name . ".tpl";
            if(file_exists($file)) {
                $this->get_title();
                $this->tpl_include = $file;
            } else {
                $this->error_handler(TPL, $tpl_name . ".tpl (" . $tpl_typ . ") ist nicht vorhande!");
            }
            
        } elseif($tpl_typ == "admin") {
            $file = $this->admin_path_tpl . $tpl_name . ".tpl";
            if(file_exists($file)) {
                $this->get_title();
                $this->tpl_include = $file;
            } else {
                $this->error_handler(TPL, $tpl_name . ".tpl (" . $tpl_typ . ") ist nicht vorhande!");
            }
        
        } else {
            $this->error_handler(TPL, "Kann ". $tpl_name . ".tpl (" . $tpl_typ . ") nicht laden!");
        }
    }
    
    function include_tpl () {
        if($this->tpl_include != "" && is_string($this->tpl_include)) {
            return include_once($this->tpl_include);
        }
    } 
PHP-Code:
	
	
<?php
$read = date("d-m-Y");
if($read == "") {
    $read = date("d-m-Y");
} 
$data = date("d-m-Y") . "<br /> \n";
$handle = file("content/admin/error_handler/" . date("d-m-Y") . ".txt");
$tpl->set_tpl("error_handler", "admin");
?>
Code:
	
	<?php 
foreach ($handle as $zeile) {
        echo $zeile . "<br /> \n";
}
?>
PHP-Code:
	
	
if(isset($include_path)) {
    if($include_typ == "index") {
        if(file_exists("content/index/". $include_path . ".php")) {
            include_once ("content/index/". $include_path . ".php");
        } else {
            $tpl->error_handler(PHPDAT, "PHP Datei:" . $include_path . " nicht vorhanden!");
        }
    }
    elseif($include_typ == "user") {
        if(file_exists("content/user/". $include_path . ".php")) {
            include_once ("content/user/". $include_path . ".php");
        } else {
            $tpl->error_handler(PHPDAT, "PHP Datei:" . $include_path . " nicht vorhanden!");
        }
    }
    elseif($include_typ == "admin") {
        if(file_exists("content/admin/". $include_path . ".php")) {
            include_once ("content/admin/". $include_path . ".php");
        } else {
            $tpl->error_handler(PHPDAT, "PHP Datei:" . $include_path . " nicht vorhanden!");
        }
    }
    else {
        include_once ("content/index/". $include_path . ".php");
    }
    
} else {
    include_once ("content/index/". $include_path . ".php");
}
include_once("content/index/tpl/html_header.tpl");
$tpl->include_tpl();
include_once("content/index/tpl/html_footer.tpl");
?> 
wenn ich eine Variable setze in datei.php und die tpl datei direkt include funktioniert der Code.
Aber wenn ich es über die funktion mache wird zwar normal es HTML ausgegeben aber nicht die Variable da steht dann NOTICE: Variable nicht gesetzt...
Aber warum werden die Variablen nicht übergeben wurde doch beides in die index geladen.
mfg Marco
 
          
 TPL System
									
									
									TPL System
								
 
							
						
Kommentar