I use #currentlink in a nav list of links to indicate which page is
currently being viewed.
The code in the nav list looks like this:
<p><a href="index.php">Home Page</a></p>
<p><a href="contact.php">Contact</a></p>
<p><a href="tech.php#tech01">tech01</a></p>
<p><a href="tech.php#tech02">tech02</a></p>
<p><a href="tech.php#tech03">tech03</a></p>
The problem is that there are 3 named anchors on the tech.php page. If
there were no named anchors, and only one link to tech.php, I could do this:
<p><span id="currentlink"><a href="tech.php">tech</a></span></p>
That would change the color of the link as desired. But because there are
multiple links on the same page, I can't do this. So I need some php to
check the current url (I think) and echo the appropriate currentlink (again,
a guess) based on the url - so only the link referencing the current named
anchor will change color.
Here's some pseudo code:
<?php
/*
if ( current url = "tech.php#tech01" )
{
make "tech.php#tech01 the currentlink
}
elseif ( current url = "tech.php#02" )
{
make "tech.php#tech02 the currentlink
}
... and so on
*/
?>
Does this sound like the right way to go about this? How do I check the
current url, and how do I then get php to say the equivalent of :
<p><span id="currentlink"><a
href="tech.php#thisLink">thisLink</a></span></p>
Any help is appreciated!
By the way, the css code looks like this:
#currentlink a:link { color:#CC0000; }
#currentlink a:visited { color:#CC0000; }
#currentlink a:hover { color:#CC0000; }
#currentlink a:active { color:#CC0000; }