Autoload function and get variables |
[eluser]Unknown[/eluser]
Hello everybody I have this question: how to load function in codeIgniter in every page and get data or variables from it to show in view? I have many controllers and each one has many function. Each function load master view as a template and load its own view. Master view has dynamic data I push it from database. So I need in master view to show some data from database automatically. How to do it?
[eluser]hungdp[/eluser]
Write a base controller to show some data you want show, and all controller extends your base controller.
[eluser]Otemu[/eluser]
Hi, Just to add too hungdp answer I have provided the following sources for you: Take a look at Phil excellent post http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY Also depending what your doing another thing that can be very useful is Modular Extensions: makes the CodeIgniter PHP framework modular. Modules are groups of independent components, typically model, controller and view, arranged in an application modules sub-directory that can be dropped into other CodeIgniter applications. https://bitbucket.org/wiredesignz/codeig...sions-hmvc And finally depending what your doing you could always create a library http://ellislab.com/codeigniter/user-gui...aries.html |
Welcome Guest, Not a member yet? Register Sign In |