• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Autoload function and get variables

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?

Write a base controller to show some data you want show, and all controller extends your base controller.


Just to add too hungdp answer I have provided the following sources for you:

Take a look at Phil excellent post

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.

And finally depending what your doing you could always create a library

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.