|
Posted by BootNic on 06/20/07 23:54
> Rich Bradshaw <Rich.Bradshaw@gmail.com> wrote:
> news: 1182365867.888535.188240@k79g2000hse.googlegroups.com
> Hi,
>
> 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.
>
> To help explain this, the page looks like this:
[snip]
> Where menu.php 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?
You appear to be using php, I suggest you go ahead and put it to work.
You will still need a style class for the current link, that will fit nicely
in your current style sheet.
The menu.php could look something like this:
<?php
$PHP_SELF = $_SERVER['PHP_SELF'];;
$navLinks = Array(
'home'=>'/temp/prev12~.php',
'our approach'=>'/approach.php',
'products & services'=>'/products.php',
'gallery'=>'/gallery.php',
'prices'=>'/prices.php',
'booking'=>'/booking.php',
'contact'=>'/contact.php',
'links'=>'links.php'
);
?>
<div id="navbar">
<ul id="navlist">
<?php
foreach ($navLinks as $key => $value) {
$class=($PHP_SELF==$value)?' class="current"':'';
echo chr(9).'<li><a href="'.$value.'"'.$class.'>'.$key.'</a></li>'.chr(10);
}
?>
</ul>
</div>
--
BootNic Wednesday, June 20, 2007 7:54 PM
War does not determine who is right, war determine who is left.
*Ancient Chinese Proverbs*
[Back to original message]
|