[eluser]lopetzi[/eluser]
Hello world,
I am new to CI, but i really like it.
I'm having one small problem:
I have a piece of code that i will have to repeat in almost every controller. Is there any way to put that code in a file and execute it... ?
home.php
Code:
class Home extends Controller {
function Home()
{
parent::Controller();
}
function index()
{
// model is autoloaded
$general = $this->general->get_general();
$template['description'] = $general->description;
$template['keywords'] = $general->keywords;
$template['price'] = $general->price;
$user = 'Guest';
$template['welcome'] = 'Welcome, ' . $user;
// all the code above will repeat in every controller
$template['title'] = 'Titlu';
$template['heading'] = 'HOME';
$template['left'] = $this->load->view('home','',true);
$template['right'] = $this->load->view('newsform','',true);
$this->load->view('main', $template);
$this->output->enable_profiler(TRUE);
}
}
I've tried to copy-paste that code into a library and then load the library, but i get an error...
How do you handle the code that repeats in your controllers ?
Thanks,
George