I am new in codeigniter. I want to load hooks for admin panel controller.
$hook['post_controller_constructor'][] = array(
'class' => 'AdminData',
'function' => 'myfunction',
'filename' => 'loginhelp.php',
'filepath' => 'hooks',
'params' => array()
);
Ok this is the simplest way to do this:
declare a public variable in your Controller
public $is_hookable = TRUE;
Then inside your hook function do this:
$ci=&get_instance();
if($ci->is_hookable){
... enter whatever you want here;
}
hope this was helpful
please read the document clearly https://ellislab.com/codeigniter/user-guide/general/hooks.html
The hooks feature can be globally enabled/disabled by setting the following item in the application/config/config.php file:
$config['enable_hooks'] = TRUE;
Hooks are defined in application/config/hooks.php file.
You cannot load it for specific controller.You need to check controller name at hooks function and write code. suppose your post_controller_constructor hooks function name is myfunction you can check it inside the function
$CI =& get_instance();
if($CI ->router->class=="AdminData"){//write your code}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With