For more information about php templates, see
The code is as follows:
Class Lightpage_Template {
Var $ Tpl_Header;
Var $ Tpl_Footer;
Var $ Tpl_Parsing;
Var $ Tpl_Template;
Var $ Tpl_Dirname;
Var $ Tpl_Parse_String;
Var $ Tpl_Parse_Array;
Var $ Tpl_Result;
Function _ construct (){
$ This-> Tpl_Header = NULL;
$ This-> Tpl_Footer = NULL;
$ This-> Tpl_Parsing = array ();
$ This-> Tpl_Template = 'list.html ';
$ This-> Tpl_ToParse = NULL;
$ This-> Tpl_Parse_String = array ();
$ This-> Tpl_Parse_Array = array ();
$ This-> Tpl_Result = NULL;
Return true;
}
Function Parse_Template (){
$ This-> Tpl_Parse_String = array ();
$ This-> Tpl_Parse_Array = array ();
If ($ this-> Tpl_Header! = NULL) {array_push ($ this-> Tpl_Parse_String, $ this-> Tpl_Header); array_push ($ this-> Tpl_Parse_Array, '{header }');}
If ($ this-> Tpl_Footer! = NULL) {array_push ($ this-> Tpl_Parse_String, $ this-> Tpl_Footer); array_push ($ this-> Tpl_Parse_Array, '{footer }');}
If (count ($ this-> Tpl_Parsing )! = 1 ){
Foreach ($ this-> Tpl_Parsing as $ Tpl_Key => $ Tpl_Value ){
Array_push ($ this-> Tpl_Parse_String, $ Tpl_Value );
Array_push ($ this-> Tpl_Parse_Array, '{'. $ Tpl_Key .'}');
}
}
If ($ this-> Tpl_Template! = NULL & $ this-> Tpl_ToParse = NULL ){
$ This-> Tpl_ToParse = file_get_contents (root. './Templates/'. $ this-> Tpl_Template );
}
$ This-> Tpl_Result = str_replace ($ this-> Tpl_Parse_Array, $ this-> Tpl_Parse_String, $ this-> Tpl_ToParse );
Return $ this-> Tpl_Result;
}
}
?>
Php template usage:
The code is as follows:
$ Mdl = new Lightpage_Template ();
$ Mdl-> Tpl_Header = 'zzz ';
$ Mdl-> Tpl_Footer = '';
$ Mdl-> Tpl_Parsing = '';
$ Mdl-> Tpl_Template = 'list.html ';
Echo $ Mdl-> Parse_Template ();