Were to store common view data |
[eluser]mptre[/eluser]
Hello! I have a question regarding "best practices" when it comes to Codeigniter. I have several controllers which uses the same views. In these views there's always some mandatory data such as the links for the navigation. I need to access this data in all my controllers. So therefor my question is where should the data be stored? Storing it inside each controller doesn't feel that efficient since I need to repeat myself. Is using a model for this considered bad practices? Thanks in advantage!
[eluser]Rob Gordijn[/eluser]
look at the following thread: http://ellislab.com/forums/viewthread/143648/
[eluser]mptre[/eluser]
Thanks! But I'm having problem getting this to work. Can't spot anything wrong with the code below. I get an error saying that data is a undefined property. Any ideas on what I'm doing wrong here? controllers/foo.php Code: <?php libraries/MY_Controller.php Code: <?php
[eluser]Rob Gordijn[/eluser]
hey you need to extend your Foo class with the MY_Controller
[eluser]momo123[/eluser]
I think it should be: class Foo extends !!!MY_Controller!!! Good luck! momo
[eluser]mptre[/eluser]
Correct my if I'm wrong. But in that case I have to write an extension foreach controller?
[eluser]Rob Gordijn[/eluser]
you create one MY_Controller, and then extend all you controllers with that one
[eluser]Michael Wales[/eluser]
Are the links for navigation actual dynamic data in which you must query a database or is it just static xHTML. If it's just static $this->load->view() can be called from within a view itself.
|
Welcome Guest, Not a member yet? Register Sign In |