I want to load multiple view from a function, devided pages into 3 parts
<?php include('header.php'); ?>
<?php include('footer.php'); ?>
You could use $this-load->view from inside each of your views, not only controllers.
So in your index.php view file, at the top you could load the header, and at the bottom the footer.
I would not use
include() in CodeIgniter at all. CI has loaders for everything you need to use inside it.
A better way to do it would be to define a library or model that would load the template.This way, if you want to change the file included at the top or bottom you don't need to change every view. Even more, you can use this load js,css, seo metadata etc. based on each controller.
The way to achieve this is (let's go the model route):
$datayou can define the keys: js, css, seo, content etc.
In your controller, return your view as data (for example index.php) and send it to the model as
$data['content'] : https://www.codeigniter.com/user_guide/general/views.html#returning-views-as-data
$this->load-model('templateModel', 'template'); $data['content'] = $this->load->view('index', '', TRUE); $this->template->render($data);
In the view rendered by your model, print content where it should display (btw header and footer).