I’m writing my own ExpressionEngine 2 extension that delegates some work to a model class. The constructor includes the line:
$this->EE->load->model('my_model')The EE control panel fails on this line when I view the addons->extensions page. The message is “Unable to locate the model you have specified: my_model”.
I’ve used a debugger to step through the CI_Loader->Model() method, and I can’t see models from my other third party add-ons, e.g. DevDevmon’s Tagger… the complete list of models it does load is:
member_model
channel_model
template_model
site_model
addons_model
super_model
addons_model
my_model… so presumably these are the only extensions which load models as part of the processing EE does when loading the addons->extensions CP page.
I can see why it fails - the list of model paths the method considers on line 172:
foreach ($this->_ci_model_paths as $mod_path)
{
if ( ! file_exists($mod_path.'models/'.$path.$model.EXT))
{
continue;
}
//...…does not include system/expressionengine/third_party/my_module/models, it only checks system/expressionengine/models. So clearly I’m doing something unusual by loading a model in the extension constructor where it will be called when the extensions control panel page loads.
That said, I can’t see any warnings in the documentation or any reason why I shouldn’t be able to do that. In my case I’ve got the same code that needs to be called by both an extension and a module and it makes sense to put this stuff in a model.
I’m pretty sure the standard “make model name lowercase” advice is irrelevant here (not least because I made sure every possible reference was lower cased)… eager to here any other ideas you may have.
Fritz
[Mod Edit: Moved to the Development and Programming forum]
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.