Ruko Posted April 15, 2010 Share Posted April 15, 2010 Im currently making template phases for the forum and its HTML templates. How do I add and make these things function. Example: <b>Hello World</b> <!-- ECHO: Hello --> <!-- INCLUDE hello.htm --> Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/ Share on other sites More sharing options...
oni-kun Posted April 15, 2010 Share Posted April 15, 2010 Those are called SSI's, Or Server Side Includes and do not relate in sense to PHP unfortunately. Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/#findComment-1042199 Share on other sites More sharing options...
andrewgauger Posted April 15, 2010 Share Posted April 15, 2010 <!--#include virtual="hello.htm" --> Oni-kun's right (as always) its Server Side Include. Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/#findComment-1042200 Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 Or write a template system that parses it and replace it with the necessary codes. Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/#findComment-1042201 Share on other sites More sharing options...
Ruko Posted April 15, 2010 Author Share Posted April 15, 2010 Quote Or write a template system that parses it and replace it with the necessary codes. Thats what im looking for. Now how do I write it, lol. Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/#findComment-1042205 Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 Grab the template file, parse it with some RegExp, and replace it with something else. Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/#findComment-1042207 Share on other sites More sharing options...
The Little Guy Posted April 15, 2010 Share Posted April 15, 2010 example: <?php $file = '/my/templates/template1.tmpl'; $handle = fopen($file, 'rb'); $str = fread($handle, filesize($file)); fclose($handle); $str = preg_replace("~<!-- ECHO:(.+?) -->~si", "$1", $str); echo $str; ?> Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/#findComment-1042211 Share on other sites More sharing options...
Ruko Posted April 15, 2010 Author Share Posted April 15, 2010 Quote example: <?php $file = '/my/templates/template1.tmpl'; $handle = fopen($file, 'rb'); $str = fread($handle, filesize($file)); fclose($handle); $str = preg_replace("~<!-- ECHO:(.+?) -->~si", "$1", $str); echo $str; ?> How about stuff like <!-- IF LOGGED IN --> or <!-- INCLUDE --> Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/#findComment-1042752 Share on other sites More sharing options...
The Little Guy Posted April 16, 2010 Share Posted April 16, 2010 <?php $file = '/my/templates/template1.tmpl'; $handle = fopen($file, 'rb'); $str = fread($handle, filesize($file)); fclose($handle); if(preg_match("~<!-- IF LOGGED IN -->~si", $str)){ // user is logged in } if(preg_match("~<!-- INCLUDE:(.+?) -->~si", $str, $matches)){ include $matches[1]; } ?> I didn't test... Link to comment https://forums.phpfreaks.com/topic/198606-how-do-i-make-stuff-like-or/#findComment-1042817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.