控制器如下:
public function index(){
$this->load->model('admin_model');
$data['users'] = $this->admin_model->get_latest_users();
$this->load->view('templates/adminhead');
$this->load->view('templates/adminheader');
$this->load->view('templates/adminsidebar');
$this->load->view('admin/index', $data);
$this->load->view('templates/adminfooter');
}
视图在浏览器中正确显示,但源代码页脚首先显示然后是主页然后显示头文件。为什么会这样?
答案 0 :(得分:2)
问题我不清楚。但我会这样做: 控制器代码:
public function __construct(){
parent::__construct();
$this->load->model('admin_model');
}
public function index(){
$data['users'] = $this->admin_model->get_latest_users();
$data['adminhead'] = 'templates/adminhead';
$data['adminheader'] = 'templates/adminheader';
$data['adminsidebar'] = 'templates/adminsidebar';
$data['adminfooter'] = 'templates/adminfooter';
$this->load->view('admin/index', $data);
}
只需将它们加载到视图上即可。