pkedpker Posted June 29, 2009 Share Posted June 29, 2009 My question may seem odd to some people who don't know what templating is.. My site before templating was a real mess a bunch of php tags and html code in each php file.. so I looked for a solution and found templating is what i need.. Now i can do nearly everything with templating that is call variables in it.. but I cannot seem to find a way to do functions.. basically here is what I do loadTemplate(blahblah) $t = file_get_contents($templateName); return "return <<<TMP\r\n\r\n{$t}\r\n\r\nTMP;\r\n"; now index is like <?php session_start(); echo eval(loadTemplate('header')); echo eval(loadTemplate('footer')); ?> a template file is basically simple HTML coded website with support for variable with the use of {$varName} its a combination of heredoc and eval.. well anyways I want to know how to call functions in it. how would i call like my old way of doing this <?php showMemberOptions(); ?> in a template? I tried {showMemberOptions()} It just echos {showMemberOptions()} I know somehow I could cuztomize the showMemberOptions function into a template with a shitload of new variables but that will be pretty crazy for me.. since showMemberOptions can show login form.. or welcome username and a bunch of other stuff.. Quote Link to comment https://forums.phpfreaks.com/topic/164166-solved-templating-function-calls-is-it-possible/ Share on other sites More sharing options...
Alex Posted June 29, 2009 Share Posted June 29, 2009 You should probably rethink your whole template system. I could give you an alternative option, but it's really not worth the trouble that it'll cost you. Quote Link to comment https://forums.phpfreaks.com/topic/164166-solved-templating-function-calls-is-it-possible/#findComment-866019 Share on other sites More sharing options...
pkedpker Posted June 30, 2009 Author Share Posted June 30, 2009 haha this cost me enough trouble converting it all to template system.. but now i can support many different styles on the website and not like my previous idea where I just had to modify a CSS file to change my site looks completely now I can actually move things around in all different designs with a set of different html templates.. and plus now my other site designers who are like 11-15 years old only understand html/css they can pick this up easily. I can see a big downside to templating.. you have to make many variables for everything.. can't just echo things out like I used to do. Quote Link to comment https://forums.phpfreaks.com/topic/164166-solved-templating-function-calls-is-it-possible/#findComment-866025 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.