gig Posted March 14, 2006 Share Posted March 14, 2006 How I can use macros in PHP code - the goal is to substitute %piece1 with block of code or function call. I need for following task - to include different piece of code based on situation. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/4953-how-to-use-macros-code-templates-in-php/ Share on other sites More sharing options...
keeB Posted March 14, 2006 Share Posted March 14, 2006 [!--quoteo(post=354950:date=Mar 14 2006, 05:06 PM:name=gig)--][div class=\'quotetop\']QUOTE(gig @ Mar 14 2006, 05:06 PM) [snapback]354950[/snapback][/div][div class=\'quotemain\'][!--quotec--]How I can use macros in PHP code - the goal is to substitute %piece1 with block of code or function call. I need for following task - to include different piece of code based on situation. Thanks in advance.[/quote][code]if ($condition) { include ("grandma");} else { include ("grandpa");}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4953-how-to-use-macros-code-templates-in-php/#findComment-17530 Share on other sites More sharing options...
gig Posted March 15, 2006 Author Share Posted March 15, 2006 [!--quoteo(post=355059:date=Mar 14 2006, 04:25 PM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 14 2006, 04:25 PM) [snapback]355059[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]if ($condition) { include ("grandma");} else { include ("grandpa");}[/code][/quote]Dear keeB,1. Thank you.2. I think, I asked wrong - what I really need is to use not runtime variables (like you suggested) but MACROS (by stating this I assumed like parser/preprocessor). So, last night I did some research via search engines and found that some preprocessor software exists that could possible help me with this.I raised question because I am not programmer (in PHP or so) - I just bought CMS where php mixed with html and I realized that in order to separate my own additions (in design or so)from existing CMS code I need some parser/preprocessor to keep all organized.3. So, if you have some experience in such things, please help me sharing with. Anyway, looks like i need preprocessor software for my purpose.Best regards, Ian Quote Link to comment https://forums.phpfreaks.com/topic/4953-how-to-use-macros-code-templates-in-php/#findComment-17836 Share on other sites More sharing options...
trq Posted March 15, 2006 Share Posted March 15, 2006 What your looking for sounds more like a templating system. If the CMS you have doesn't have one then it would be pretty difficult to encorperate without knowing php, but there are plenty of templating engines around. Some simple, some quite advanced. Quote Link to comment https://forums.phpfreaks.com/topic/4953-how-to-use-macros-code-templates-in-php/#findComment-17867 Share on other sites More sharing options...
gig Posted March 17, 2006 Author Share Posted March 17, 2006 [!--quoteo(post=355405:date=Mar 15 2006, 12:30 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Mar 15 2006, 12:30 PM) [snapback]355405[/snapback][/div][div class=\'quotemain\'][!--quotec--]What your looking for sounds more like a templating system. If the CMS you have doesn't have one then it would be pretty difficult to encorperate without knowing php, but there are plenty of templating engines around. Some simple, some quite advanced.[/quote]Well, CMS I got has templating system (and macros - as its written on PHP) already. Plus studying PHP a little last night I found way how to add additional conditional inserts via PHP functions calls in my CMS - like what you suggested in the beginning.And finally I found the solution - this is PPWizard - preprocessor that have enough power to cover my needs.Big thanks for last link ;-) Quote Link to comment https://forums.phpfreaks.com/topic/4953-how-to-use-macros-code-templates-in-php/#findComment-18281 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.