fusionpixel Posted December 8, 2006 Share Posted December 8, 2006 I am creating a simple site that will be edited by several people and I would like to set up a simple sistem similar to what templates use{header}instead of header()I was looking at some template solutions but they are too big for what I am trying to acomplish. so in short I was wondering what is the best way to convert header() into {header}. Is there any simplified way to do it?TIA Quote Link to comment https://forums.phpfreaks.com/topic/29981-creating-templates/ Share on other sites More sharing options...
redbullmarky Posted December 8, 2006 Share Posted December 8, 2006 the regular armoury of PHP's search+replace functions will do the trick. in terms of templating, [url=http://www.php.net/preg_replace]preg_replace[/url] will do nicely, but be prepared to enter the murky world of regular expressions :)however - there's plenty of info in the 'Regex board' here:http://www.phpfreaks.com/forums/index.php/board,43.0.htmlif its just templating to the point where you want to seperate your main code from your views, then it maybe worth taking a read through (my favourite!!!!) this:http://www.massassi.com/php/articles/template_engines/Hope that helpsMark Quote Link to comment https://forums.phpfreaks.com/topic/29981-creating-templates/#findComment-137749 Share on other sites More sharing options...
fusionpixel Posted December 8, 2006 Author Share Posted December 8, 2006 Humm, that seems interesting. I am familiar with regexp and will look more into that. At least with the reading I have made to the site you point me out to I have adjusted my template from<? echo header(); ?>to<?=$header;?>it think it will be easier for people to remember just to type <?=$header;?> but we will see.I will look into how to replace the {} for actual content.THX Quote Link to comment https://forums.phpfreaks.com/topic/29981-creating-templates/#findComment-137755 Share on other sites More sharing options...
redbullmarky Posted December 9, 2006 Share Posted December 9, 2006 no worries.what many coders that use template engines need to kinda realise is that, unless your coder is a donkey, typing <?=$header ?> really isnt too much harder than typing {header}. as that article explains, and as i've come to realise through my own toying around, PHP is a perfectly good templating engine itself. obviously beware of sites that have the short tags (like <? and <?=) turned off, but it seems to be on by default these days and signs suggest that even PHP6 will continue to support the short tags/alternative syntax (like foreach/endforeach, if/elseif/endif, etc)good luck. Quote Link to comment https://forums.phpfreaks.com/topic/29981-creating-templates/#findComment-137804 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.