Page 1 of 1

Best way to implement PHP template

Posted: Fri Apr 22, 2011 11:22 pm
by Lemonz
Hey guys. I want to make a template in PHP but am not sure where to begin. I googled how to create your own template but the results did not satisfy me. They were very basic and was not what I was looking for. I want to make a template where only the content changes but by a navigation bar. Now I know in PHP you can use the $_GET function and based on the variable you are given you display that particular page in the template. However the problem with this is, if you have a lot of pages in your website, your index.php file is going to be huge and only consist a list of "if" and "if else" statements comparing the variable to each type of page you have. I want to avoid this. So is there any other efficient way of creating such a template in php or how can I change the content of the template efficently? Any other help on template creating would be much appreciated.

Re: Best way to implement PHP template

Posted: Sat Apr 23, 2011 12:35 am
by Christopher
Look into Front Controller and dispatch. Instead of lots of if()s, you generate a file name using the parameter value and load that file as the content.