Muffinresearch Labs by Stuart Colville

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:

Diagram of Directory Structure

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.

Post Tools

Comments: Add yours







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



GNU screen: open tab in current working directory|(1)

A nice trick for having screen open a new tab in the same directory as the one you’re currently in. To use it add it to your .screenrc

# Open new window in current dir.
bind c stuff "screen -X chdir \$PWD;screen^M"
bind ^c stuff "screen -X chdir \$PWD;screen^M"

Hat tip: mteckert on SuperUser.com

Ubuntu: add-apt-repository: command not found|(2)

When you’re using a minimal Ubuntu install if you find the ‘add-apt-repository’ command is missing (it’s useful for adding PPAs and other repositories), then simply run:

sudo apt-get install python-software-properties

Photos on Flickr

© Copyright 2004-12 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.494s.