![]() |
Call a constructor value in my view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Call a constructor value in my view (/showthread.php?tid=6158) |
Call a constructor value in my view - El Forum - 02-16-2008 [eluser]breaddes[/eluser] I set the following in my controller constructor: Code: $this->countries = array('Deutschland'=>'de', 'Belgien'=>'be', 'Lichtenstein'=>'li', 'Luxemburg'=>'lu', 'Österreich'=>'at', 'Schweiz'=>'ch'); Now I would like to use $this->countries in my view. Normally I would send it with my $data-parameter, but I need that in each function of my controller and I think there must be a better way to do it so. Otherwise I would have to write 10 times $data['countries'] = $this->countries. Call a constructor value in my view - El Forum - 02-16-2008 [eluser]Seppo[/eluser] You can call Code: $this->load->vars(array('country' => $this->countries)); Call a constructor value in my view - El Forum - 02-16-2008 [eluser]breaddes[/eluser] great. works out! Call a constructor value in my view - El Forum - 02-16-2008 [eluser]breaddes[/eluser] I've done it in a model which autoloads. There's still one thing ... I can use country in my views, but how can I use it in my controller then? Edit: I've got it. Just call $this->language_model->countries |