Welcome Guest, Not a member yet? Register   Sign In
Newbie Q: Setting Global vars in a controller
#3

[eluser]erik.brannstrom[/eluser]
I'm not sure exactly what it is you wish to achieve? Do you mean that you don't want to repeat setting for example the css and js values in multiple methods? If so, this should do the trick.

Code:
<?php

class Gigiem extends Controller {
  private $data = array(
      'css' => array('html5'),
      'js' => array('site'),
      'static' => 'http://www.mysite.com/static/',
      'title' => 'Welcome!'
  );

  // index() ...

  function work()  {
    $this->load->model('work_model');
  
    $this->data['view'] = 'work';
    $this->data['title'] = 'Previous Work';
    $this->data['projects'] = $this->work_model->getRecent(2);
    
    $this->load->view('slate', $this->data);
  }

}


Messages In This Thread
Newbie Q: Setting Global vars in a controller - by El Forum - 05-03-2010, 10:04 AM
Newbie Q: Setting Global vars in a controller - by El Forum - 05-03-2010, 10:38 AM
Newbie Q: Setting Global vars in a controller - by El Forum - 05-03-2010, 10:40 AM
Newbie Q: Setting Global vars in a controller - by El Forum - 05-03-2010, 12:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB