CodeIgniter Forums
Get current page so I can set the style to "active" in menu? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Get current page so I can set the style to "active" in menu? (/showthread.php?tid=2485)



Get current page so I can set the style to "active" in menu? - El Forum - 08-08-2007

[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.


Get current page so I can set the style to "active" in menu? - El Forum - 08-08-2007

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

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

if you are not using codeigniter try to use server variables


Get current page so I can set the style to "active" in menu? - El Forum - 08-08-2007

[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-guide/libraries/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!


Get current page so I can set the style to "active" in menu? - El Forum - 08-08-2007

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

Example Navigation helper example


Get current page so I can set the style to "active" in menu? - El Forum - 08-08-2007

[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.