if you want to pass all the time the same variables in all the views and this variables not change, you can do like you say : extend CI_Controller with your MY_Controller and after all your controllers extend MY_Controller.
Note that :
My_Controler.php will be in directory named "core" of the directorys "application". No need to put it in the directory "core" of your directory "system".
application/core/MY_Controller.php
PHP Code:
defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Controller extends CI_Controller
{
private $items ;
public function __construct()
{
parent::__construct() ;
$this->init() ;
$this->load->vars($this->items );
}
private function init()
{
$this->items = array('some_var' => '....',
'new_var' => '...') ;
}
}
Your other controllers in directory Controller
PHP Code:
defined('BASEPATH') OR exit('No direct script access allowed');
class C extends MY_Controller
{
private $vue = '.......' ;
public function __construct()
{
parent::__construct() ;
}
public function index()
{
$this->load->view($this->vue) ;
}
}
In your view
PHP Code:
$v = $this->load->get_var('some_var') ; // or only call $some_var