Create a strong website structure
Published on March 5, 2010 @ 2:09 pm
This tutorial will give you insight on how to create a strong dynamic website structure using PHP.
Step 1 – Create the layout
First things first, before you can do anything with PHP, you need to create a strong website layout. For this tutorial you will be using a simple CSS layout that consists of the following elements:
1. Wrapper
2. Header
3. Navigation
4. Sidebar
5. Content
6. Footer
The diagram below illustrates the website layout for this tutorial.
Step 2 – Create 5 new php files
Now that the website structure has been created, it is time to start making it dynamic. To do this you will firstly need to separate the main layout elements. In this case it will be the; Header, Navigation, Sidebar, and Footer.
Create five new PHP files and name them accordingly; header.php, navigation.php, sidebar.php, footer.php and also index.php.
Remove all the information within these five files so they are completely blank. Save these files to the rootfolder of the website.
Step 3 – Separating the layout
This step is a little bit tricky, but with enough practice it becomes very simple!
You are now going to take the code from the template design file and place them in the files that you have just created. For precaution you may want to create a copy of the template file (index.html if you downloaded the files), in case you muck it up.
Step 4 – navigation.php
Begin with the navigation.php file.
Go to your template file (index.html) and highlight from the beginning of the navigation Div to the end of the navigation Div tag.
Copy and paste this into the navigation.php file and save it.
<div id=”navigation”>
Navigation
</div>
Step 5 – sidebar.php
Highlight from the beginning of the sidebar Div tag to the end Div tag.
Copy and paste theis selection into the sidebar.php file and save it.
<div id=”sidebar”>
Sidebar
</div>
Step 6 – footer.php
Highlight from the end content Div tag to the


