I'd like to turn on my class "selected" (which is a hover basically) when I'm on the corresponding category. Pretty much the active hover thing.
Here's how I'm trying to do it:
$url = $this->getLink($menu);
$current_url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$selected = (strpos($url, $current_url) !== false) ? true : false;
Thing is: it's working pretty well when the URL is like: http://my-website.com/en/15-this-categorie
But it does turn on every hover when the URL is: http://my-website.com/en/ where here, none of the hover are supposed to be turned on.
Need help here!
So thanks for all your answers :D
I solved this by comparing the id, this was actually the easiest way and the most logical one
$url = '/'.$menu['item'].'-';
$current_url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$selected = (strpos($current_url, $url) !== false) ? true : false;
$menu['item'] get the category id btw