Welcome Guest, Not a member yet? Register   Sign In
Setting variables to be used controller wide.
#8

[eluser]InsiteFX[/eluser]
CroNiX showed you how to do it above
Code:
class Something extends CI_Controller {

  //Declare the property
  public $timezone_drop = array();

  function __construct()
  {
    parent::__construct();

    $this->timezone_drop = array(
       '' => 'Select Timezone',
        1 => 'Eastern',
        2 => 'Central',
        3 => 'Mountain',
        4 => 'Pacific',
        5 => 'Alaskan',
        6 => 'Hawaiian',
    );
  }

  function index()
  {
    $this->data['timezone'] = $this->timezone_drop;  //although, its already available throughout your controller as $this->timezone_drop, so not sure why you are assigning it to another variable

    // this will make it global to all your controllers and views. So now you do not need to pass it
    $this->load->vars($this->data);
  }
}


Messages In This Thread
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 01:11 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 02:33 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 02:45 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 02:58 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 03:50 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 03:58 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 04:02 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 04:15 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 05:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB