chmpdog Posted March 1, 2009 Share Posted March 1, 2009 Hi, Earlier this year I started my website, I thought I didn't need a good template engine, so I made one. Well now I have realized that was a bad Idea. I have run into problems w/ headers and page titles, so now I am looking for an easy template engine to implent in my current system. Heres how my system works, I have all the includes in folder, and then there is a variable to set the page title. Do any of you guys know a template engine that operates like this? Quote Link to comment https://forums.phpfreaks.com/topic/147435-php-template/ Share on other sites More sharing options...
premiso Posted March 1, 2009 Share Posted March 1, 2009 Why use a template engine? PHP is it's own template engine. Simple as this: index.tpl.php <html> <title><?php echo $title; ?></title> // display the body items <!-- include the foot --> <?php include($_SERVER['DOCUMENT_ROOT'] . '/templates/footer.tpl.php'); ?> </html> index.php <?php //if some condition true // other processing here also $title = "Main Index"; include($_SERVER['DOCUMENT_ROOT'] . '/templates/index.tpl.php'); ?> No need to go and create a whole new system for something PHP was really designed todo. Quote Link to comment https://forums.phpfreaks.com/topic/147435-php-template/#findComment-773832 Share on other sites More sharing options...
a-scripts.com Posted March 1, 2009 Share Posted March 1, 2009 yeah .. I think that using template engines is waste of time when you can use the natural PHP templates like premiso suggested. I've also written a short article about it some time ago http://www.a-scripts.com/general-php/2009/02/23/separate-logic-and-presentation-use-templates/ Quote Link to comment https://forums.phpfreaks.com/topic/147435-php-template/#findComment-773922 Share on other sites More sharing options...
chmpdog Posted March 7, 2009 Author Share Posted March 7, 2009 index.tpl.php <html> <title><?php echo $title; ?></title> // display the body items <!-- include the foot --> <?php include($_SERVER['DOCUMENT_ROOT'] . '/templates/footer.tpl.php'); ?> </html> index.php <?php //if some condition true // other processing here also $title = "Main Index"; include($_SERVER['DOCUMENT_ROOT'] . '/templates/index.tpl.php'); ?> Thats what I have, except on my index I have php include another file to get variables for the page title and content. It works if I set my variable on index, but it doesn't if it is set in the other file. Quote Link to comment https://forums.phpfreaks.com/topic/147435-php-template/#findComment-778668 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.