0

hey guys, im trying to change a menu items color, if a user was on the members section, the member menu icon would be a different colour to the other menu items etc.

initially the menu item <li> has no css class assigned to it, but once they visit a page, the <li> tag is assigned a class ie .visited{colour:#fff;)

its implemented in php, firstly ive got a url check to see what page the current url is on, and then change the class

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 if($pageURL=="http://mysite.com/")
 {
     return 

 }
 else if($pageURL=="http://mysite.com/category.php?id_category=26")
 {
     help here..
 }
 else if($pageURL=="http://mysite.com/cms.php?id_cms=16")
 {
     and here..
 }
 else if($pageURL=="http://mysite.com/cms.php?id_cms=31")
 {
     and here..
 }
 else if($pageURL=="http://mysite.com/cms.php?id_cms=22")
 {
     and here..
 }



}

as you can see above, im finding it hard to finish the last piece to this puzzle.. how to change the class of the li tag to a different one. would really appreciate any input.

Cheers

D

Edited by matrixracetips

2
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by matrixracetips
0

I am not strong on PHP, but I would suggest that you look into doing this client side, using jQuery. You can easily add or remove classes. Take a look: http://api.jquery.com/addClass/

on the client-side, you can use the same approach to check the current URL, then add/remove the class as needed.

0

sorry forigve my lastreply, it works, but there because initally it had a hover styling ,where when the user hovers over a menu item, it reverts back to its original class

Edited by matrixracetips

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.