[eluser]John-Doe[/eluser]
How can I load a model in my MY_Loader.php -file in directory "application/core"?
Im trying to group my loader-views into a MY_Loader -file for more convenient loading of the views. I want to pass dynamic values to the header to customize the title output.
My code looks like this:
Code:
private $ci;
public function __construct()
{
parent::__construct();
// Initiate instance
$this->ci =& get_instance();
// Load model
$this->ci->load->model('My_loader_model');
}
public function template($template_name, $vars = array(), $return = FALSE)
{
$data_header['inbox_messages'] = $this->ci->My_loader_model->inbox_messages_count();
$content = $this->view('header', $data_header, $return);
$content .= $this->view($template_name, $vars, $return);
$content .= $this->view('footer', $vars, $return);
if ($return)
{
return $content;
}
}