CodeIgniter Forums

Full Version: Get current page so I can set the style to "active" in menu?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]See64[/eluser]
I just can't find how to do this simple thing best: I am including a view called menu.php in my default view. Here I build the navigation according to your rights. This all works great, except how do I set the current page's class to something else? There is nothing in the URL helper to return the current page, and searching the forums didn't bring up anything, so I'm at a loss.

El Forum

[eluser]emperius[/eluser]
are you using codeigniter?

if the answer is yes than try to use http://ellislab.com/codeigniter/user-gui...s/uri.html
ans than a simple "if" conditional statement

if you are not using codeigniter try to use server variables

El Forum

[eluser]See64[/eluser]
[quote author="emperius" date="1186600732"]are you using codeigniter?

if the answer is yes than try to use http://ellislab.com/codeigniter/user-gui...s/uri.html
ans than a simple "if" conditional statement

if you are not using codeigniter try to use server variables[/quote]

Cheers emperius, that looks like something I can use. I was looking in the wrong place: I thought this would be something like a variable called "current_class" or something. Thanks!

El Forum

[eluser]mezoni[/eluser]
Code:
global $class, $method;
variables help you to solve this problem.

Example Navigation helper example

El Forum

[eluser]See64[/eluser]
[quote author="mezoni" date="1186604163"]
Code:
global $class, $method;
variables help you to solve this problem.

Example Navigation helper example[/quote]

Thanks mezoni, but I have a disliking of globals Wink I find that the above solution by emperius works very well, and is perhaps the easiest way.