CodeIgniter Forums
Functions in views ... how to organize them. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Functions in views ... how to organize them. (/thread-28638.html)



Functions in views ... how to organize them. - El Forum - 03-17-2010

[eluser]behdesign[/eluser]
In my current project, I'm trying to keep php in views to a minimum, so I'm delegating rendering things like lists to functions in the library that's assembling all the different views to one page (header view, content view, etc). The problem is this: there are going to be a LOT of these helper functions as I'm going along - 2-3 per page. Instead of cluttering up the one library, I wanted to organize them in another way. My question is: what funcions are available in a view? I thought about using a helper (or more than one), but that means calling get_instance() in every helper function that needs access to model data. What other functions are available to views, or is there a different way that I could organize these sorts of view functions?


Functions in views ... how to organize them. - El Forum - 03-17-2010

[eluser]danmontgomery[/eluser]
Helpers are the best way... As long as a helper is loaded anywhere before the view is called, you don't need to call get_instance() in the view... Those functions are now globally accessible.