Separate each section of your site into different directories (as per your navigation scheme) and then you can highlight your navigation based, very simply, on which directory the current page is running under. Try something like this:
//Include this in your functions.inc.php file, or wherever you prefer to store your funtions for global access.
#<cwd_short>
//A function that returns ONLY the current directory name and not its full path.
function cwd_short() {
//Now, let's get the CWD (Current Working Directory) name,
//covering our bases for both Windows and *NIX platforms.
if (strchr(getcwd(), '/') == FALSE) {
$cwd = strrchr(getcwd(), '\\');
}
else {
$cwd = strrchr(getcwd(), '/');
}
//Remove any leading slashes from what's left of the CWD.
$to_replace = array('\\', '/');
$cwd = str_replace($to_replace, '', $cwd);
return $cwd;
}
#</cwd_short>
//Include this in your global.inc.php file, or whever you put commonly-accessed arrays for use on your site. Obviously, replace my values here with yours.
//Let's create an array of the various directories in the cart
//so we know which step of the checkout process to highlight in the status bar.
$checkout_dirs = array(
'cart' => 'Shopping Cart',
'billing' => 'Billing',
'shipping' => 'Shipping',
'shippingmethod' => 'Shipping Method',
'ordersummary' => 'Order Summary'
);
//You will have to modify this a little bit to suit your needs, but it should do the job.
//Okay, here's the deal. We have a globally-accessible array called $navigation_dirs that stores
//the directory names of each step in the path-to-purchase. This little loop does two
//things: 1) it checks the current working directory (cwd) and highlights the text
//description of the active step, and 2) it checks to see which of those text descriptions
//should be clickable. Part 2 is determined by whether or not a given step has
//been completed (and that information is stored in the session array $_SESSION['tracking'][$k . '_completed'],
//where $k is the key [and therefore directory] name for the section in the foreach loop).
$counter = 0;
foreach ($navigation_dirs as $k=>$v) {
$counter ++;
echo '<td nowrap="nowrap"';
if (cwd_short() == $k) {
echo ' class="shoppingcart_step_selected" ';
}
echo '>';
if ($_SESSION['tracking'][$k . '_completed'] == 1) {
echo '<a href="' . $root . "shopping/$k" . '" class="no_underline">' . $v . '</a></td>';
}
else {
echo $v . '</td>';
}
//We don't need to add a spacer after the last link.
if ($counter != count($navigation_dirs)) {
echo '<td width="32"> </td>';
}
}