Welcome Guest, Not a member yet? Register   Sign In
Current controller
#1

[eluser]Mat-Moo[/eluser]
What's the best way to get the name of the current controller? I was looking at uri_segments() but I only want the first segment...
#2

[eluser]gullah[/eluser]
$this->uri->segment(1);
#3

[eluser]Mat-Moo[/eluser]
I should of guessed really, but wiki just says it return all - TY.
#4

[eluser]LuckyFella73[/eluser]
Hi Mat-Moo,

in case you make use of ci routing, the first
url segment may be not the same as the name of your controller.

in that case better write:

Code:
get_class($this)

to get the name of the current controller.

Cheers - Luckyfella
#5

[eluser]Mat-Moo[/eluser]
I have a common header and want to highlight the correct tab for the page your on. but that might be helpful Smile ty
#6

[eluser]louis w[/eluser]
I think __CLASS__ would work too.




Theme © iAndrew 2016 - Forum software by © MyBB