Welcome Guest, Not a member yet? Register   Sign In
Current page and 'active' class in menu
#3

(This post was last modified: 06-07-2015, 02:54 PM by gadelat.)

uri->segment returns only one segment. Segments are split by slashes. So it can't be 'main/index'. One segment is either 'main' or 'index'. If you have all stuff in one controller, you don't really need controller check, so use just the second segment, like
PHP Code:
<?=($this->uri->segment(2)==='index')?'active':''?>

You can also use router->fetch_method instead, which is more reliable as it is less prone to errors caused by changes in urls, routing config and/or .htaccess
Reply


Messages In This Thread
RE: Current page and 'active' class in menu - by gadelat - 06-07-2015, 02:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB