Welcome Guest, Not a member yet? Register   Sign In
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

Theme © iAndrew 2016 - Forum software by © MyBB