Best way to implement PHP template
Moderator: General Moderators
Best way to implement PHP template
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.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Best way to implement PHP template
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.
(#10850)