Techrits Posted August 15, 2012 Share Posted August 15, 2012 Hello friends, I need to display which link/menu is selected in the navigation bar of my website. My navigation bar contains diff menus like home, contact us etc. if people selects contact us then it should stay highlighted. So please reply if you know how to do this in php/css/html only (because I don't have knowledge of other web development lang.) Thanks and regards. Link to comment https://forums.phpfreaks.com/topic/267109-navigation-bar-problem/ Share on other sites More sharing options...
ManiacDan Posted August 15, 2012 Share Posted August 15, 2012 Wherever you output the menu, check to see which page you're on and change the color of that menu item. Link to comment https://forums.phpfreaks.com/topic/267109-navigation-bar-problem/#findComment-1369560 Share on other sites More sharing options...
Techrits Posted August 15, 2012 Author Share Posted August 15, 2012 Wherever you output the menu, check to see which page you're on and change the color of that menu item. Exactly correct but I'm having only one nav-bar in my site (which is unique to all menus and pages) and to make code reliable I include that code (nav-bar) in one file and using php all pages includes that same file so the thing you mentioned will not work here. Link to comment https://forums.phpfreaks.com/topic/267109-navigation-bar-problem/#findComment-1369567 Share on other sites More sharing options...
Jessica Posted August 15, 2012 Share Posted August 15, 2012 Yes, it will. In fact that's the best way to do it. Have one php file for your nav bar, and check what page you are on, then have it output certain code based on that. Link to comment https://forums.phpfreaks.com/topic/267109-navigation-bar-problem/#findComment-1369570 Share on other sites More sharing options...
ManiacDan Posted August 15, 2012 Share Posted August 15, 2012 Exactly correct but I'm having only one nav-bar in my site (which is unique to all menus and pages) and to make code reliable I include that code (nav-bar) in one file and using php all pages includes that same file so the thing you mentioned will not work here. This is the only way my suggestion will work. Inside your nav include file, when you print the menus, change the color of the menu item which corresponds to the page you're on. Link to comment https://forums.phpfreaks.com/topic/267109-navigation-bar-problem/#findComment-1369573 Share on other sites More sharing options...
Techrits Posted August 15, 2012 Author Share Posted August 15, 2012 @ManiacDan Yes but how to do it with css and html as which conditions should I check I need hint on this point. Link to comment https://forums.phpfreaks.com/topic/267109-navigation-bar-problem/#findComment-1369630 Share on other sites More sharing options...
jazzman1 Posted August 15, 2012 Share Posted August 15, 2012 Take a look at here -> http://stackoverflow.com/questions/6761118/change-css-property-dynamically-in-php Link to comment https://forums.phpfreaks.com/topic/267109-navigation-bar-problem/#findComment-1369635 Share on other sites More sharing options...
ManiacDan Posted August 15, 2012 Share Posted August 15, 2012 Yes but how to do it with css It's your page, not mine. Change the colors, make it bold, whatever. You "do it with CSS" the same way you do anything with CSS: give it a special class. and html as which conditions should I check I need hint on this point.This...makes no sense, but again, it's your site and not mine. How do you determine which page you're on? However you determine that (url, filename being called, a variable called $page), check that against the nav items you're printing when you print them. If the page you're on matches the nav item you're about to print, make it a different color or size or whatever. Link to comment https://forums.phpfreaks.com/topic/267109-navigation-bar-problem/#findComment-1369645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.