Here's a quick tip to have a simple template-based website. I use this method on my Textpattern-powered site and it works great!
This method does not requires any installation of PHP template engines such as Smarty, XTemplate, etc. All it takes is 2 lines in your .htaccess file.
Well, how am I doing it?
Sort answer: using Apache directives.
Longer answer: using Apache directives to auto-append and auto-prepend header and footer files.
To achieve this, do the following:
- Create an HTML/PHP file with your design layout.
- Break this file into 3 portions, before dynamic content, content, and after dynamic content.
- Save the before portion as head
er.php and the after portion as footer.php in your server’s root directory.
- In your
.htaccess, add the following lines:
php_value auto_prepend_file /header.php
php_value auto_prepend_file /footer.php
- That’s it.
Now, create your website as you normally would. Every time your pages will load, Apache will automatically “wrap” them with your header and footer files, producing your desired end result.
I recommend using the .html file extension for the header and footer files to save server load if your pages are not dynamic pages.
PLEASE NOTE: Your webhost may not allow you to use these Apache directives, so be sure to check that out before hand.