Reputation: 422
I have many helper functions that require access to get_instance(). For example, here is a function to get a list of members for use in a dropdown:-
function get_members_list()
{
$EE =& get_instance();
$EE->load->model('member_model');
// rest of my code
return $members_list;
}
I put it in a helper because there's a lot of extra code in here, something I would not consider suitable for model, but more for a controller. And then because several libraries/controllers are accessing it, I thought move it a helper.
So my question is, is it OK to use get_instance() and load helpers, within helper functions? I have get_instance() used many times in my helper file, because each function needs to call it.
Or is there a way for helpers to access get_instance() that is already loaded in the controller/library that is loading the helper?
Thanks
Upvotes: 0
Views: 164
Reputation: 2563
I would put it in a library.
How you organize things is really up to personal preference, but having a library would make the most sense. You can group it by data type, or just have a single library class for key/value data (for use in drop downs).
Upvotes: 1