• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Model --> Config or Model-->Controller-->View?

#1
[eluser]brucebat[/eluser]
Hi all hope your having a nice summer.

I am trying to figure out the best way of parsing values from my database to a web form.

These values are used for my pulldowns , javascript validation, etc.


I was thinking of using a config file (is this the correct use of one?) or should I just stick to using a controller to pass it to the view?

What is your opinions?

Thanks

#2
[eluser]Nisha S.[/eluser]
Best way is to get it to the controller and then pass it to the view.

#3
[eluser]brucebat[/eluser]
[quote author="Nisha S." date="1310740607"]Best way is to get it to the controller and then pass it to the view.[/quote]

Thanks so what is a Config for then?

#4
[eluser]Aken[/eluser]
Adding those options to the config (either the existing one or your own) would be just fine.

You'd then call the specific config items needed in your controller, then pass them on to the view.

I myself actually did something similar to this, except I created a helper file with different functions for generating drop-down menus and such.

#5
[eluser]Angel Web Design[/eluser]
Or you could use the constructor method to get the data if it is required on every page and save it in an array, then pass the array through to the view.
Code:
__construct(){

    $this->data['my_menu'] = $this->my_model->get_menu();
}

function index(){
    $this->data['page_specific_data'] = "something";
    $this->load->view('index', $this->data);
}

#6
[eluser]Eric Barnes[/eluser]
Config files are for basically storing for static variables that really don't change.

In your case I would go with the controller method or use helpers. That is what helpers are for. Help you do tasks. Wink


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.