CodeIgniter Forums
Using a helper function in the View file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Using a helper function in the View file (/showthread.php?tid=51256)

Pages: 1 2


Using a helper function in the View file - El Forum - 04-26-2012

[eluser]CroNiX[/eluser]
Kind of hard to use the captcha_helper, form_helper, download_helper, table_helper, html_helper, smiley_helper, typography_helper and some others without using them in views. They're really designed for that purpose, and they mostly deal directly with outputting HTML, so they really belong in the view most of the time.

If you disagree, perhaps you might be able talk the CI developers into changing the user guide for the "helpers" section.
Quote:CodeIgniter does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, it becomes globally available in your controller and views.

If they didn't intend on us being able to use helpers in views, they probably wouldn't specifically say they're available to them.


Using a helper function in the View file - El Forum - 04-26-2012

[eluser]Aken[/eluser]
Using helper functions in views is really dependent on who will be maintaining the view files, or if you make theming available through your application (like a CMS or something). If you want things to be as plain and simple as possible, don't use them (or use them and make some sort of document available that explains them). If it's not a big deal, use them to your heart's content.