|
Posted by Beauregard T. Shagnasty on 06/20/07 19:44
Rich Bradshaw wrote:
> Sorry about the long title - I have a page with a navbar on. I would
> like like to make it so that the links that link to the page the user
> is on are a different color.
>
> The problem is, that I want to keep the menu in a file so that I can
> server side include it, so I don't want to have to change it manually
> for each page.
Like this: http://countryrode.com/ ?
> To help explain this, the page looks like this:
<snip>
> Obviously there is some css formatting here as well.
>
> If we are on contact.php, I want the link to contact.php to be styled
> differently so that we know where we are.
>
> Is there any way to do this without getting rid of the server side
> include or drastically making the site more complex?
I do this by assigning a variable to each page. Place this before
calling the include. Such as:
$imenu = 1; // Number of this page and menu item
Then the menu include file uses:
echo "<div id=\"boxnav\"><!-- Begin menu -->\n";
echo "<ul id='crmenu'>\n";
/* Each menu button */
if ($imenu<>1) { echo "<li><a href='../main/index.php'>Home</a></li>\n";
} else { echo "<li class='mbreak'>Home</li>\n";}
...with subsequent lines in the include for each of the items. Each is
just one long line (not wrapped). The next:
if ($imenu<>2) { echo "<li><a href='../main/shop.php'>In The
Shop</a></li>\n"; } else { echo "<li class='mbreak'>In the
Shop</li>\n";}
...and so forth, and ends with:
echo "</ul>\n";
echo "</div><!-- End menu -->\n";
Class 'mbreak' just shows the word in a different color. Note that the
button is not a clickable link to the same page.
If you have pages that are not on the menu, e.g. called from a link in
the content somewhere, use: $imenu = 0;
There may be easier ways, but this is what I came up with on the spur of
the moment several years ago.
--
-bts
-Motorcycles defy gravity; cars just suck
[Back to original message]
|