• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get name of controller from view (without passing it as a variable)

Is there a native way to get the name of the controller from within a view?

echo __CLASS__;

This still has to be done from the controller because in the view the class is CI_Loader

You could do a good old:

$current_controller = $this->uri->segment(1);
echo $current_controller;

And that would certainly work from a view. If you're talking about it happening on the client end you would need to use javascript to get the same effect.

I'm not aware of any problems that would occur using this method.


works for me so far Wink

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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