My_Controller says this:
class BaseController extends My_Controller {
// public $data;
public function __construct() {
parent::__construct();
// $this->get_right();
}
public function get_right(){
$data['rightinfos'] = $this->Com_model->get_top20info();
$data['right0'] = $this->Com_model->get_site_new();
$data['right1'] = $this->Com_model->get_site_hot();
$data['right2'] = $this->Com_model->get_site_hot2();
return $data;
}
}
Then I am in the site controller:
class Site extends BaseController {
public function __construct() {
parent::__construct();
$this->load->model('Site_model');
}
public function page() {
$data=$this->get_right();
print_r($data);
die();
//***
This is currently feasible, but the sentence $data=$this->get_right();
must be written in the page method.
Feels inconvenient. If I want to get $data
after __construct, how should I write it?