I am trying to pull a listing of custom channel fields in my module and am refactoring to use EE models.

I tried


but that didn't set $this->EE->field_model... as expected.

Any idea on how to use EE models in my module?

  • 1
    Please note the use of $this->EE implies that the latter code is in your module's controller (or other module file which requires the use of $this->EE =& get_instance();). Commented Feb 26, 2013 at 15:44

3 Answers 3


Another approach might be to turn your module into a package. You could put this in in your module's constructor (or a superclass to subclass it from for use in more than one class):


Now mymodulename/models will be added as a path for your model files. and mymodulename/helpers for your helper files. You can then load the model.


Looks like it works inside of my module's models BUT in a "Controller (mcp)" $this->EE->field_model doesn't seem to be accessible.

Simply use the following in the model instead:

  • 1
    Can you please edit your original question to include this information. We keep the answers section for actual answers. Thanks :) Commented Feb 26, 2013 at 6:08
  • Hi Adrian, I volleyed between adding it as a comment and an answer myself and found it was more suitable in the answers section. The solution is to add the call to load the model in your module's models. Commented Feb 26, 2013 at 15:41
  • You should definitely be able to load models in your controller though, so I'd be interested to find out why that's not working. Is is possible to post a link to the source of your full mcp file? Commented Feb 27, 2013 at 6:18

For anyone else expiriencing same issue, make sure the model's file name is lowercase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.