Answer the question
In order to leave comments, you need to log in
How to connect the views I need automatically?
Good time.
The procedure for connecting views in the controller now looks like this:
$this->load->view("document_top"); //Тут doctype и начала контейнера html
$this->load->view("document_head"); //Тут контейнер head и начало тега body
$this->load->view("users");
$this->load->view("document_bottom"); //Тут конец контейнеров body и html
echo "</body></html>";
Answer the question
In order to leave comments, you need to log in
in no case can you edit the framework classes directly, create the base class MY_Controller.php in it, connect the necessary views, as an option, create a method in MY_Controller
protected function renderPage($page,$data = []) {
$html = $this->load->view("document_top",[],true);
$html .=$this->load->view("document_head",[],true);
$html .= $this->load->view($page,$data,true);
$html .= $this->load->view("document_bottom",[],true);
$this->output->set_output( $html );
}
class User extends MY_Controller {
public function Index(){
$userlist = [];
// logic
$this->renderPage('users',[
'userlist' => $userlist
]);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question