Better simple site structure | Comments (0)
Posted in Muffin Research Labs on 18th June 2004, 5:08 pm by Stuart
I decided to look at this site’s directory structure as I knew that the way I had put it together was not the most logical. I had created the layout for the site the way I had always done, however, having checked out sites like zeldman.com et al, that there was a better way.
What I did was rearranged the structure so that each navigational item was now in it’s own directory. Like this:

This also meant that CSS stylesheets and any source files were now referenced using relative values to the site root. Now CSS is accessible from any new directory on the site which is a lot better that having “../../main_styles.css” all over the place. Ok so that’s an exaggeration but it’s so much better having one way of defining a stylesheet’s location.
This method will really help when I come to write the archiving sections for the blog script. : )
The site was now in a much better shape. I also got rid of the daft and unecessary css and php includes that gave each page it’s different graphic in the header2 div. I replaced them with simple inline styles that overwrite the original value in the main stylesheet!
The only issues I had were when I tried to use relative links to the php includes starting with a “/”. I then found out that PHP includes are run relative to the script that uses them. What I did to resolve this was to remove all references to directories from the includes. That means you are left with for example:
include 'header.php';include 'nav.php';
Instead of:
include '/adirectory/header.php';include '/adirectory/nav.php';
I then used a “.htaccess” file to specify the location of my included files so that php knows where to look for them. This file goes in the site root.
php_value include_path "/home/virtual/var/www/directory/"
This resulted in a much easier way to take care of future php include files.
