Welcome Guest, Not a member yet? Register   Sign In
Call a constructor value in my view
#1

[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.
#2

[eluser]Seppo[/eluser]
You can call
Code:
$this->load->vars(array('country' => $this->countries));
on you constructor, so the data will be on all controllers methods views
#3

[eluser]breaddes[/eluser]
great. works out!
#4

[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




Theme © iAndrew 2016 - Forum software by © MyBB