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
You can setup a class property named data and then set it's default values into the contructor which is the first thing which is run when a new instance on Basic
is created.
Then you can reference to it with the $this
keyword
class Basic extends Controller
{
var $data = array();
public function __construct()
{
parent::__construct();
// load config file if not autoloaded
$this->data['title'] = 'Page Title';
$this->data['robots'] = 'noindex,nofollow';
$this->data['css'] = $this->config->item('css');
}
function index()
{
$this->data['my_data'] = 'Some chunk of text';
$this->load->view('basic_view', $this->data);
}
function form()
{
$this->data['my_data'] = 'Another chunk of text';
$this->load->view('form_view', $this->data);
}
}