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

[eluser]josepichu[/eluser]
Hi!

Can i aply a hook in a unique controller ??? how??

edit: I have my index controller and the rest, but I only want to execute an auth function to the rest of controllers. T have made this:

Code:
$hook['pre_controller'] = array(
                                'class'    => '',
                                'function' => 'control_auth',
                                'filename' => 'control_auth.php',
                                'filepath' => 'hooks'
                                );

but with this code control_auth.php is execute in all the application controllers. I have seen the user guide.

thks!
#2

[eluser]Luis ACE[/eluser]
hi josepichu,

Yes you can apply a hook only for a unique controller. You need to update your hook code to check which controller is called.

Code:
$current_controller = $this->CI->router->fetch_class();

if($current_controller == 'welcome')
{
//Execute code
}

you might need to change hook point from pre_controller to post_controller_constructor.
#3

[eluser]josepichu[/eluser]
thanks very much!!




Theme © iAndrew 2016 - Forum software by © MyBB