I have a query that gets one random record from a database table and saves it in, $banner_text I am having trouble showing that banner text in my template though.
Below is my code for MY_Controller which all my other controllers extend, I wanting to use this to send $banner_text to whatever template/layout is being built.
class MY_Controller extends Controller {
function __construct() {
parent::Controller();
$this->load->model('banners_model');
//$this->output->enable_profiler(TRUE);
$this->template->set_theme('moovjob');
$this->template->set_layout('main');
//$this->banners_model->get_header();
//$this->template->title('Some title');
//$this->template->build('main');
}
}
To load a variable globally in all views loaded by this controller ( or child controller ) use…
( Part of the Loader Class )
so in your case.
class MY_Controller extends Controller {
Now
$banner_textwill be available in all views loaded by this controller.}