I am working on a project using HMVC codeigniter. i have my own library for layouts and my base controller named MY_Controller with this code:
class MY_Controller extends MX_Controller{
public $layout='layout_name';
public $theme='name';
...
public function __construct(){
parent::__construct();
...
}
}
my problem is: when i use $this->CI=& get_instance();
in the library, the properties of my controller like $theme
are unavailable. for example can not use $this->CI->theme;
but in the controllers no problem exist and i can use $this->theme;
anywhere. how can i make an instance contain my base controller variables in the library?
Solved. according to the CI documentation, i use second parameter of loading library and send my specified variables to library via array. in the mx_controller:
class MY_Controller extends MX_Controller{
private $layout='default';
private $theme='white';
private $param=array();
public function __construct(){
parent::__construct();
$this->param=array('layout'=>$this->layout,'theme'=>$this->theme);
$this->load->library('lib',$this->param);
}
}