[eluser]bennyhill[/eluser]
for my main controller, I have a bunch of reoccurring variables in each function in the class. For example,
Code:
$data['css'] = $this->config->item('css')
is declared in every function. I tried declaring the $data array variable at the top of the class, then populating it with the reoccurring values in the constructor but I get undefined variable errors for $css and $base in the view. Any advice on how to keep redundant variable definitions to a minimum in codeigniter?
example
Code:
class Catalog extends Controller{
$data;
function Catalog(){
parent:Controller();
$data = new array();
$data['css'] = $this->config->item('css');
$data['base'] = $this->config->item('base_url');
}
function index($v){
$data['value'] = $v;
$this->load->view('home', $data);
}
}