I've added "header_model" into codeigniter's autoload.php file. now its:
$autoload['model'] = array("header_model");
And i also can successfully use $this->header_model
in other controllers.
But can't use it in MY_Loader
class, which is extension of CI_Loader
.
Example: Pages controller located at application/controllers/:
class Pages extends CI_Controller {
public function view($page = 'home')
{
var_dump($this->header_model->get_menus()); //echoes data from database.
}
}
MY_Loader class (located at application/core/ folder):
<?php
class MY_Loader extends CI_Loader {
function __construct()
{
parent::__construct();
}
public function template($template_name, $vars = array(), $return = FALSE)
{
$menuArray = $this->header_model->get_menus(); //echoes errors
//like: Undefined property: MY_Loader::$header_model
$vars["menuArray"] = $menuArray;
}
}
Thanks for any help.