Welcome Guest, Not a member yet? Register   Sign In
parse url, class=active
#1

[eluser]benfike[/eluser]
Hi!

Code:
<?php $page = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); ?>
                        <? $page_exploded = explode('/', $page, 2);
                        if (count($page_exploded) == 2){
                            $address = $page_exploded[0];
                            $controller = $page_exploded[1];
                        }
                        ?>
                            <li &lt;?php if ($controller == 'admin/overview') { ?&gt;class="active"&lt;?php } ?&gt;><a class="nav-icon icon-house" href="&lt;?=base_url()?&gt;admin/overview">Áttekintés</a></li>

So if $controller = admin/overview then set li class="active"....

It works fine, but it dont work when there is a function for overview controller, example: add, modify etc.

what can I do?

or there is a easiest way to make something like this?

Sorry for my english;
#2

[eluser]Victor Michnowicz[/eluser]
A better way to get the current class and method:

Code:
$this->router->class;
$this->router->method;
#3

[eluser]benfike[/eluser]
thanks Tongue




Theme © iAndrew 2016 - Forum software by © MyBB