CodeIgniter Forums
general functions (non-class specific) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: general functions (non-class specific) (/showthread.php?tid=7370)



general functions (non-class specific) - El Forum - 04-05-2008

[eluser]richthegeek[/eluser]
Hi,

How do I create general functions - or rather, where do I put them? Is there a file that I can put them in or do I have to put it in the form of a helper?


general functions (non-class specific) - El Forum - 04-05-2008

[eluser]richthegeek[/eluser]
ok, just looked at the existing helpers - they seem to fulfill my needs entirely.

For those that looked at this looking for the answer (rather than to answer it):

- for general functions create a file in the "system/helpers" directory. They follow the format "name_helper.php", so for "general", call it "general_helper.php"

- just put them in standard function format - nothing fancy

- load them by editing the "autoload.php" config file, changing helper list to include the name of your helper.

- and your done.


general functions (non-class specific) - El Forum - 04-06-2008

[eluser]webthink[/eluser]
Or if you don't need them loaded on every request
$this->load->helper('general_helper');


general functions (non-class specific) - El Forum - 04-06-2008

[eluser]Derek Allard[/eluser]
Ah, thanks for writing back with a solution. So often I see "help me" and then "nevermind, I got it", and of course that doesn't help out future searchers Wink

Just to add this this, could can also add your specific helpers into application/helpers/ if you wanted to, may make upgrading easier, depending on how you do it, but there is no technical advantages to this if you have only 1 app running off CI.