Can you query data and return it from CI_Controller? |
[eluser]sessions[/eluser]
I am using a default layout, then nesting the view I need for a particular page. A stripped down simple example: Code: <!DOCTYPE html> Where $viewToLoad will be the name of the nested view to load. My issue is I have navigation in the default layout that is the same for every page of the site. The nav items are queried from a db. So I thought since the nav data will be the same for every page on the site, that I should gather the data in CI_Controller...correct? But right now the issue is calling this: $this->load->model("Model"); from inside CI_Controller doesn't find the model, so I can't get the data. If this is the correct approach, how do I get data returned to CI_Controller? Thanks
[eluser]Otemu[/eluser]
Hi, you could use MY_Controller which would extend CI_Controller, then have all your controllers extend MY_Controller, this way all controllers will now have to your nav data, instead of calling model from every controller just to load the navigation. Or You could use HMVC - this way you could just drop the navigation as a module Resources: Putting useful stuff in MY_Controller Creating Core System Classes [email=https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc ]HMVC[/email] Keeping it DRY |
Welcome Guest, Not a member yet? Register Sign In |