mathewjenkinson Posted April 27, 2009 Share Posted April 27, 2009 ive got a vertical menu system stored in a mysql db thats called when a page loads. is there a way I can use a tag or parameter to highlight what page you are on? at present im using: <ul> <li><a href="#" tabindex="1">What We Do</a></li> <li><div class="active"><a href="#" tabindex="2">Education</a></div></li> <li><a href="#" tabindex="3">Research</a></li> <li><a href="#" tabindex="4">Grants and Awards</a></li> <li><a href="#" tabindex="5">National Societies</a></li> <li><a href="#" tabindex="6">EONS Newsletter</a></li> <li><a href="#" tabindex="7">News</a></li> <li><a href="#" tabindex="8">Events</a></li> </ul> with the div class identifying what page the user is presently on. This means putting the whole menu system into each page where it would be easier to load from a single file. Would it still be possible to highlight what page the user is on? Link to comment https://forums.phpfreaks.com/topic/155836-highlighting-users-location-from-a-generic-menu-file/ Share on other sites More sharing options...
sloth456 Posted April 27, 2009 Share Posted April 27, 2009 Sure, just do something like this for each item in the menu <li><?php if($_SEVER['php_self']=="THE FILENAME HERE"){echo "<div class='active'><a href='#' tabindex='1'>What We Do</a></div>";}else{echo "<a href='#' tabindex='1'>What We Do</a>";}</li> $_SERVER['php_self'] contains the file the user currently has active, so for each item on the menu you just check the filename against $_SERVER['php_self']. If $_SERVER['php_self'] equals the file specified for the menu item, highlight it, otherwise don't. I hope I'm making sense and I hope that helps. Link to comment https://forums.phpfreaks.com/topic/155836-highlighting-users-location-from-a-generic-menu-file/#findComment-820268 Share on other sites More sharing options...
mathewjenkinson Posted April 28, 2009 Author Share Posted April 28, 2009 Fantastic Thank you very much, would that work even if I used url_rewrite? Link to comment https://forums.phpfreaks.com/topic/155836-highlighting-users-location-from-a-generic-menu-file/#findComment-821394 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.