Reputation: 10745
I have some common functions that I've written that I'm currently copying in to each of my controllers. An example is a method that puts together my main navigation - I'm currently copying it in to each and every one or my controllers.
Is there any way I can put these common functions somewhere so I don't have to repeat the same code in each controller?
I thought creating core classes in the user guide would be it but that only seems to be to extend the current core
Upvotes: 1
Views: 1901
Reputation: 12826
There is a whole bunch of ways to do this:
Usually in CI, helpers are just files with a bunch of "helper" functions. Libraries are better organized into classes. Personally, I would create a custom lib called Common
or maybe specialize them further like a Nav Lib
or so. Thats why I love CI its so simple yet flexible!
Upvotes: 2