
mam taki mały problem ;/ , napisalem sobie prosta klase do obslugi szablonow ktorej kod widzicie tutaj :
<?php class template{ private $root; function __construct($root){ $this -> root = $root; }else{ } } // end __construct($root); function loadFileS($file){ }else{ foreach($file as $handle => $FILE){ }else{ } } } } // end loadFileS($file); function loadFile($handle, $file){ }else{ } } // end loadFile($file); function addVars($handle, $values){ }else{ foreach($values as $tag => $value){ $this -> template[$handle][$tag] = $value; } } } // end addVars($handle, $values); function addVar($handle, $tag, $value){ $this -> template[$handle][$tag] = $value; } // end addVars($tag, $value); function pparse($handle){ foreach ($keys as $key) { $this -> files[$handle] = str_replace($key, $this -> template[$handle][$key], $this -> files[$handle]); } } return $this -> files[$handle]; } // end parse(); function parse($handle){ } // end parse($handle); } ?>
natomiast tak wyglada zastosowanie tego w praktyce :
<?php include ("tpl.class.php"); $tpl = new template("tpl"); 'index' => 'index.tpl', 'heder' => 'heder.tpl', 'bottom' => 'bottom.tpl' )); '{TITLE}' => 'Spokojnie, to tylko test!', '{META}' => '', '{BGCOLOR}' => '#f0f0f0', '{KODOWANIE}' => 'iso-8859-2' )); '{TEXT}' => 'jakis tam sobie text', '{TEXT_DWA}' => 'kolejny bzdurny text'
)); '{HEDER}' => $tpl -> pparse('heder'), '{TRESC}' => 'Tutaj powinna znajdować się właœciwa treœć strony :)', '{BOTTOM}' => $tpl -> pparse('bottom') )); $tpl -> parse('index'); ?>
i niby wszytsko jest ok, ale ja bym chcial zrobic taki bajer ze gry zamieniam jakis znacznik z szablonu dajmy na to {TEXT} chcialbym uzyc '{TEXT}' => require('plik.php') no i wlasnie tu jest problem bo zamiast ladnie podminic sformulowanie {TEXT} i wrzucic plik w to miejsce co trzeba to tak nie jest, plik jest includowany od tak sobei na poczatku strony
czy jest jakis sposob zeby cos zty m zrobic
