I\'m a very newbie on CodeIgniter, and while I go on I run into problems that, in the procedural coding, were easy to fix
The current issue is: I have this controlle
What you can do is make "class variables" that can be accessed from any method in the controller. In the constructor, you set these values.
class Basic extends Controller {
// "global" items
var $data;
function __construct(){
parent::__construct(); // needed when adding a constructor to a controller
$this->data = array(
'title' => 'Page Title',
'robots' => 'noindex,nofollow',
'css' => $this->config->item('css')
);
// $this->data can be accessed from anywhere in the controller.
}
function index(){
$data = $this->data;
$data['my_data'] = 'Some chunk of text';
$this->load->view('basic_view', $data);
}
function form(){
$data = $this->data;
$data['my_other_data'] = 'Another chunk of text';
$this->load->view('form_view', $data);
}
}