Welcome Guest, Not a member yet? Register   Sign In
Loading libraries and models in view?
#1

[eluser]Alias M2K[/eluser]
Just wanted to know... Is that possible? :grrr:
#2

[eluser]axiom82[/eluser]
Loading libraries and models into views is not a good programming practice.

What you should do is load libraries and models into controllers. Store the return data of your libraries and models into an associative array and plug that into your view.

Here is an example:

Code:
function my_page(){

    $this->load->library('some_library');
    $this->load->model('some_model');

    $data = array(
        'library_data' => $this->some_library->get_some_data(),
        'model_data' => $this->some_model->get_some_data();
    );

    $this->load->view('some_view', $data);

}

In your view, reference the variables set in $data. These would be $library_data and $model_data. Of course, the names of these references are completely editable.
#3

[eluser]InsiteFX[/eluser]
Loading Libraries and Model in a view is breaking the MVC standard!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB