unidox Posted July 21, 2008 Share Posted July 21, 2008 Lets say I have an .htm page called page.htm. Inside index.php is this: $template = file_get_contents("page.htm"); $template = str_replace("<{CONTENT}>",include("content.php"),$template); Would that work, or how else would I do it? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 21, 2008 Share Posted July 21, 2008 No. You'd need to access content.php through the HTTP wrapper. $template = file_get_contents("page.htm"); $template = str_replace("<{CONTENT}>",file_get_contents("http://www.yoursite.com/content.php"),$template); But quite frankly, that's a horrible templating system. Why not use Smarty? Quote Link to comment Share on other sites More sharing options...
unidox Posted July 21, 2008 Author Share Posted July 21, 2008 Can I ask what smarty is? Quote Link to comment Share on other sites More sharing options...
marcus Posted July 21, 2008 Share Posted July 21, 2008 Um, lol, there's a lot easier way of doing it without using Smarty. <?php function tpl($output){ $find = array("<{CONTENT}>","<{FOOTER}>"); $repl = array(file_get_contents("content.php"), file_get_contents("footer.php")); return str_replace($find, $repl, $output); } ob_start("tpl"); echo "<{CONTENT}>"; echo "<{FOOTER}>"; ob_end_flush(); ?> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 21, 2008 Share Posted July 21, 2008 Smarty is a lot easier to work with, honestly. It has some pretty nice features and a great cache system. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.