Hi, PHP relative newbie here. I have used the following code:
obtained from elsewhere (I give full credit to whoever created it) and it works good to highlight the link of the page the visitor is currently on. Actually it even strips it of its link-like nature altogether.Code:$menu=file_get_contents("nav.php"); $base=basename($_SERVER['PHP_SELF']); $menu=preg_replace("|<li><a href=\"".$base."\">(.*)</a></li>|U", "<li class=\"current\">$1</li>", $menu); echo $menu;
Now I am trying to adapt this script to work with a menu that has subnavigation, like so (using list-item "Asian" as our working example):
(Keep in Mind that the "Asian" list item is only one LI in the main navigation.)Code:<li><a href="eating-out-asian.php">Asian</a> <ul id="asianSub"> <li><a href="eating-out-asian.php#Chinese">Chinese</a></li> <li><a href="eating-out-asian.php#Japanese">Japanese</a></li> <li><a href="eating-out-asian.php#Korean">Korean</a></li> <li><a href="eating-out-asian.php#Thai">Thai</a></li> <li><a href="eating-out-asian.php#Vietnamese">Vietnamese</a></li> <li><a href="eating-out-asian.php#Other">Other</a></li> </ul> </li>
So far I have adapted the script to:
Which works good to get rid of the opening A tag, but I haven't been able to figure out yet how to get rid of the respective closing A tag without also getting rid of all the closing A tags in the whole list.Code:$menu=file_get_contents("subnavEO.php"); $base=basename($_SERVER['PHP_SELF']); $menu=preg_replace("|<li><a href=\"".$base."\">|U", "<li class=\"current\">", $menu); echo $menu;
I'm going to keep trying to figure out a solution but if anybody else can before I do the help is appreciated in advance.






Bookmarks