Welcome Guest, Not a member yet? Register   Sign In
Getting Controller name in post_controller_constructor hook
#1

[eluser]Majd Taby[/eluser]
Hey, in hooks.php, is there a way to get the controller name? I have a hook that redirects to a login page, but i want to know the name of the controller it is redirecting from, such that when the user logs in successfully, he can be redirected there.
#2

[eluser]PERR0_HUNTER[/eluser]
I wonder if you ever got a solution to this problem
#3

[eluser]WanWizard[/eluser]
You could use the output of debug_backtrace() to find what has called your method.
#4

[eluser]Jelmer[/eluser]
You might try this:
Code:
$ci = get_instance();
$controller_name = get_class($ci);

The CI superobject is your controller (extending CI_Base and Controller).
#5

[eluser]danmontgomery[/eluser]
Code:
$CI =& get_instance();
$class = $CI->router->class;
#6

[eluser]PERR0_HUNTER[/eluser]
Wonderful! One last question Smile is there any way of also knowing what Method is being called ? right now I'm exploring the URI class to see if there's anyway I can get this info, also I came across this Filter System which I think does what the original author and I are intending to do http://codeigniter.com/wiki/Filters_system/
#7

[eluser]danmontgomery[/eluser]
Code:
$CI =& get_instance();
$method = $CI->router->method;




Theme © iAndrew 2016 - Forum software by © MyBB