Welcome Guest, Not a member yet? Register   Sign In
Use a model in view without controller
#1

[eluser]Unknown[/eluser]
I'm currently looking for a solution for the following problem.

I generate a custom menu in one of my views from my database. The MySQL query is in the faq_model. I already autoload my faq_model from the autoload.php configuration file to prevent the need to load it in every controller. The view is loaded in every controller as:

Code:
$data['faqcategories'] = $this->faq_model->getcategories();
$this->load->view('templates/metro/navbar',$data);

In the view I use a for loop to use this results.

The problem is that I currently have to use the line:
Code:
$data['faqcategories'] = $this->faq_model->getcategories();
in every single function in every controller and I want to get rid of that.

What is the best practice in a case like this? This is my first MVC project and I want to optimize my code.

Thank you in advance.


Messages In This Thread
Use a model in view without controller - by El Forum - 08-14-2013, 01:05 PM
Use a model in view without controller - by El Forum - 08-14-2013, 01:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB