You are here: Re: Change color of links that have a target of the page on which they are found. « HTML « IT news, forums, messages
Re: Change color of links that have a target of the page on which they are found.

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 &amp; 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*

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация