[eluser]differ[/eluser]
Hi,
I encountered problem in loading model/library from hook. Hook is specified on pre_controller. Is there any way to load model?
Tricks connected with:
Code:
$ci =& get_instance();
$ci->load->model('model');
... does not work. When trying to load:
Code:
$this->load->model('model_name');
PHP throws error:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Welcome::$model_name
Filename: libraries/Loader.php
Line Number: 980
I forgot about fatal error:
Quote:Fatal error: Call to a member function _assign_libraries() on a non-object in /system/libraries/Loader.php on line 980
My example hook controller:
Code:
class Example extends Controller
{
public function __construct()
{
parent::Controller();
}
public function hookFunc()
{
$this->load->model('model_name');
}
}
... and hooks config:
Code:
$hook['pre_controller'] = array(
'class' => 'Example',
'function' => 'hookFunc',
'filename' => 'Example.php',
'filepath' => 'hooks'
);
Where is the problem? Any advice will be appreciated.