betsy_ls Posted August 19, 2009 Share Posted August 19, 2009 I am extremely new to PHP and am not sure if I am even posting this in the correct place. Please forgive me if I don't explain this the right way. I am helping out a friend by editing his website that someone else wrote. The website has a top navigation dropdown menu. He wants the active page link to be a different color than the others (the same color as the hover). This is a link to the website... http://66.147.242.84/~gttgrpco/htdocs/index.php Here is the css for the navigation menu... #nav_box { color:white; background:white; width:851px; padding:1em 3em 1em 3em; height:2.25em; clear:both; float:left; } .menu { width:100%; height:2.25em; background:transparent; float:left; } .menu ul { padding:0; margin:0; } .menu ul li { float:left; width:14%px; display:inline; position:relative; list-style: none; } .menu ul li a, .menu ul li a:visited { display:block; text-decoration:none; font-weight:normal; color:#555555; padding:.25em 1em 0 1em; border-top: 1px silver solid; border-bottom: 1px silver solid; font-size: .9em; line-height:2.25em; } .menu ul ul { display: none; position:absolute; } .menu ul li:hover a, .menu ul li a:hover, .active{ color:#336699; } .menu ul li:hover ul{ display:block; position:absolute; float:left; width:100%; margin-top:.2em; margin-left:2em; padding-left:1em; font-size: .9em; top:2.5em; border-bottom: 1px silver solid; border-left: 1px silver solid; border-right: 1px silver solid; background:white; color:white; } .menu ul li:hover ul li a{ background:white; display:block; border:0; margin:0; color:#555555; font-size:1em; height:auto; line-height:1em; padding:5px; width:10em; } .menu ul li:hover ul li a:hover{ color:#336699; } And here is the php code from the navigation file... <?php $str = "<div id=\"nav_box\">\n"; $str .= "<div class=\"menu\">\n"; $pages = array('index'=>' HOME ', 'about_nogo'=>' ABOUT US ', 'services_nogo'=>' SERVICES ', 'press_nogo'=>' PRESS ', 'portfolios'=>' PORTFOLIOS ', 'contact_nogo'=>' CONTACT US ', 'innovators'=>' INVENTORS '); $pages_about = array('culture'=>'Our Culture','team'=>'Management Team','technology'=>'Technology Focus','blog'=>'Blog'); $pages_services = array('patent_sales'=>'Patent Asset Sales','patent_acquisition'=>'Patent Acquisition','patent_valuation'=>'Patent Valuation','services'=>'Other Services'); $pages_press = array('news'=>'Press Releases', 'events'=>'Events'); $pages_contact = array('headquaters'=>'Headquaters', 'email'=>'Email Us'); foreach($pages_about as $key=>$val){ if($page == $key) {$top = 'about';}} foreach($pages_services as $key=>$val){ if($page == $key) {$top = 'services';}} foreach($pages_press as $key=>$val){ if($page == $key) {$top = 'press';}} foreach($pages_contact as $key=>$val){ if($page == $key) {$top = 'contact';}} foreach($pages as $key => $val) { $str .= "<ul>\n"; if($page == $key) { $str .= "<li><a href=\"$key.php\" class=\"active\">".$val."</a>\n</li></ul>\n"; } else { if(eregi(( '([a-z]+)_nogo'), $key, $info)) { if ($top == $info[1]) { $str .= "<li><a href=\"#nogo\" class=\"active\">".$val."</a><ul>\n"; } else { $str .= "<li><a href=\"#nogo\">".$val."</a><ul>\n"; } foreach(${'pages_' . $info[1]} as $key => $val) { $str .= "<li><a href=\"".$key.".php\">".$val."</a></li>\n"; } $str .= "</ul></li></ul>\n"; } else { $str .= "<li><a href=\"$key.php\">".$val."</a></li></ul>\n"; } } } echo $str; ?> </div> </div> I understand most of the css, but the php is like a foriegn language to me. Thanks for your help. Please let me know if you need anything else. Betsy Quote Link to comment https://forums.phpfreaks.com/topic/171018-navigation-menu-active-page-help/ Share on other sites More sharing options...
Monadoxin Posted August 19, 2009 Share Posted August 19, 2009 The PHP is already creating the page, with the active link with the class of active. In the CSS edit the .active class color attribute. Quote Link to comment https://forums.phpfreaks.com/topic/171018-navigation-menu-active-page-help/#findComment-901964 Share on other sites More sharing options...
betsy_ls Posted August 19, 2009 Author Share Posted August 19, 2009 I tried that, but it is not working. Maybe I am not doing it correctly. What am I supposed to change in the above CSS? Quote Link to comment https://forums.phpfreaks.com/topic/171018-navigation-menu-active-page-help/#findComment-901972 Share on other sites More sharing options...
Monadoxin Posted August 19, 2009 Share Posted August 19, 2009 I read somewhere once that class changes in CSS sometimes don't take effect when they are in an ID section. Change the class="active" to id="active" and in the CSS use: #active { color: #somecolor; } If not, I am not sure. I am shaky in CSS. Quote Link to comment https://forums.phpfreaks.com/topic/171018-navigation-menu-active-page-help/#findComment-901985 Share on other sites More sharing options...
betsy_ls Posted August 19, 2009 Author Share Posted August 19, 2009 Ta dah!!! It worked. Thank you so much for you help. Quote Link to comment https://forums.phpfreaks.com/topic/171018-navigation-menu-active-page-help/#findComment-902007 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.