Code: Select all
<?php
$menu = <<<MENU
<ul id="navlist">
<li class="first"><a href="About_Me.php" title="you know you want to learn more about me">About Me</a></li>
<li><a href="Skillset.php" title="I've got skillz">Skill set</a></li>
<li><a href="Hireme.php" title="I can do wonders for your web presence">Hire Me</a></li>
<li><a href="Portfolio.php" title="web sites, graphics, newsletters">Portfolio</a></li>
<li><a href="Contact.php" title="how to get in touch with me">Contact</a></li>
<li><a href="Resume.php" title="my beautiful resume">Résumé</a></li>
<li><a href="http://inspiredevolution.blogs.com/inspiredevolutioncom/" title="the blog of Inspired-Evolution.com" >Blog</a></li>
<li class="last"><a href="RSS.php" title="Syndication that is really simple" >RSS</a></li>
</ul>
MENU;
$lines = split("\n", $menu);
foreach ($lines as $line) {
$current = false;
preg_match('/href="([^"]+)"/', $line, $url);
if (substr($_SERVER["REQUEST_URI"], 0, 5) == substr($url[1], 0, 5)) {
$line = str_replace('<a h', '<a id="current" h', $line);
}
echo $line."\n";
}
?>My version can be seen here:
http://www.inspired-evolution.com/About_Me.php
the CSS is supposed to be different to indicate the page you are on using the following:
ul#navlist li#active a#current
{
color: #fff;
background-color: #789;
padding:.5em 1em .5em 1em;
}
I also tried just using a#current and that doesn't work either.
I was hoping maybe someone else is using this type of menu code and can offer suggestions as to what I am doing wrong.