This is a hard thing to get your head around, I agree. What you’re going to need to do is get your navigation to be “smart”. What I mean by that is you’re going to need to add some PHP logic to the navigation footer that “reads” the URL of the current page and determines where it is in the hierarchy, and then calculates the correct number of hops to any other folder. Imagine the following:
You work out a way to get the same footer into every page. I still maintain that the correct way to do this is with the htaccess trick.
Now, in that footer, rather than a static HTML representation of the links, you have a function which can create a prefix for the links, and then an array of links to apply the prefix to.
Something like this?
//in your auto-prepend file:
define('SITE_ROOT',dirname(__FILE__);
//in your page
$here = dirname(__FILE__);
require_once(SITE_ROOT . '/smart_footer.php');
//in smart_footer.php
$base = count(preg_split('~/~',SITE_ROOT,-1,PREG_SPLIT_NO_EMPTY));
//$base is now a number representing the distance of the site root from the server's filesystem root
$offset = count(preg_split('~/~',$here,-1,PREG_SPLIT_NO_EMPTY));
//$offset is now the same thing for the current page
$shim = str_repeat('../',$base - $offset);
$options = array('folder/subfolder/page.php'=>'Something','page.php'=>'Something Else','folder/'=>'Folder');
$nav = '<p class="footer">';
foreach($options as $p=>$o){
$nav .= '<a href="' . $shim . $p . '">' . $o . '</a> ';
}
$nav .= '</p>';
Now really this should get wrapped up in a function, rather than all this procedural code lying around loose, but that’s the basic premise. You get the main auto-include file to declare where it is, then the page declares where it is, and between those two vectors you figure out how far to navigate UP before navigating back DOWN.
I have not tested any of this, it may not work at all, but it would be easy enough to try it out and see if it’s going to work.
Otherwise, you can do the same thing except with the URI, which is easily read and understood from the individual page level using the superglobal $_SERVER['REQUEST_URI']
.
Walter
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options