One of the most asked questions I get, is "How do I make a basic templating system in php?" Okay, well it's not. Actually the most common questions I get is, "Can you make a basic template system for me?"
While I have no problems helping people, and slaving for them all day long, there comes a time when you must teach a person to fish, rather than always catching the fis for them.
So here Goes
A One page template system
Now all though this is called a "one page" template system, it really doesn't use just one page. It uses a total of 3. The reason it's called a "One Page" system, is because "one page" does all of the work. The files you will be creating are as follows:
- index.php
- template.html
- content.php
You've guessed right, if you figured that content.php will be where all of your content is stored, template.html is your template, and index.php is the PHP script that puts them all together, and runs your site.
Now, there are many types of template systems. However, they all have the same concept, and pretty much work the same. The difference is, some template systems use a large number of pages, for each content portion of your site. Since that system still leaves you to create a new page for each portion of your content, it's probably not as efficient. So, for this article I'll stick with the One Page System.
So let's get started!