Need help with my Own Template System


I tray to make my Own Template System with a Design System included ^^

But i have a Problem with my Design System.

This is how it sould look like.


//Init Design
$design = new template

//Start Design

$testvar = 1;
$msg = ‘This is Ok’;

if($testwar != 1) {
$msg = “Error”;

echo $msg;

//Stop Design


I want that my Design System Knows that all between $design->designStart(); and $design-designStop(); is Content and replace {CONTENT} with it.

But i don’t know how to do so.

Hope you can Help me with my problem (maybe with a Code example).

MFG Blackfire499

Is this just pseudo-code or do you have a template class? If you have more code you should add it.

Thats my Class right now


<?php class template { var $file; var $keys = array(); var $keys2 = array(); var $out; function initFile($file) { $this->file = $file; $this->out = file_get_contents($this->file); } function set($key,$value) { $this->keys[$key] = $value; } function setArray($ar) { foreach ($ar as $key => $value) { $this->keys[$key] = $value; } } function setTandH($sitetitle,$hmenu) { $this->keys2['SITETITLE'] = $sitetitle; $this->keys2['HMENU'] = $hmenu; } function initDesign($folder) { $this->file = "designs/".$folder.'/index.htm'; $this->out = file_get_contents($this->file); $this->keys2['MENU'] = getmenu(); $this->keys2['CONTENT'] = "hi"; } function desingStart() { } function designStop() { } function out() { foreach ($this->keys as $key => $value) { $this->out = str_replace('{_'.$key.'_}', $value, $this->out); } return $this->out; } } ?>


And i dont know what i need to do for the Content ^^

Or would it be possible to filter out all variables with $design ??

Sponsor our Newsletter | Privacy Policy | Terms of Service