template

How to create a basic PHP template

by Kev on 9 February, 2009

When you’re creating a website with lots of pages all using the same look and feel, headers, CSS etc, it obviously makes sense to create a simple template.

Begin by creating a page in XHTML/HTML that looks and works exactly as you wish. Now cut and paste the header into a new file and put it into a folder called /includes/ on your server. This should be saved as something like header.php. Don’t worry that it’s not actually PHP code, that doesn’t matter. Do the same thing for your main navigation (the navigation that will remain the same throughout). You could put that in header.php but I like to keep it separate just in case there are rare cases where the navigation isn’t needed on a particular page. If you have subnavigation that changes section by section isolate that and put it in its own php file and finally, do the same thing for your footer. [click to continue…]

Use Facebook to Comment on this Post