• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.