• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best Strategy for Dynamic Header and Footer sections?

#15
[eluser]fchristant[/eluser]
My strategy for this (having common, dynamic data available in each view):

- create a base controller class
- make sure all your controllers extend the base controller class
- in the base controller class, create a public object or array, let's say $data
- in the constructor of the base controller, fill $data with whatever you like

Now, from any view (including a header) you can access this variable using:

$this->data['your property']

I like this method because in your actual controllers you need no additional lines of code. Likewise, your views do not need to load other views, or worse, libraries.

Not saying this is perfect or anything, it's just that it worked really well for me.

Bonus tip: Having a base controller is useful for other things as well. For example, I can dynamically load javascript libraries this way, and my header gets updated automatically to do that.


Messages In This Thread
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 11:41 AM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 12:05 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 02:14 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 04:35 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 04:46 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 05:30 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 05:37 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 06:40 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 06:50 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 06:52 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 07:25 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 07:25 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 08:03 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 12-02-2008, 08:07 PM
Best Strategy for Dynamic Header and Footer sections? - by El Forum - 01-03-2009, 10:36 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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