Hello,
We are developing two modules and would like to use the models from one in the other. Does anyone know if this is possible?
We have tried a few different things and can’t get it working
$this->load->model('../../other_third_party_module/models/mymodel');
var_dump($this->Mymodel); // this does not work
$mymodel = Mymodel(); //this worksAny advice would be a great help.
Many thanks,
Malcolm
This might be a stupid question, but have you tried $this->mymodel? (lowercase)
Also, I’d suggest using the constant PATH_THIRD in your page instead of using relative folder changes:
$this->EE->load->model( PATH_THIRD . '/other_module/models/mymodel');Also, don’t forget you can add a parameter to load->model if you want to specify what the module should be called:
$this->EE->load->model( PATH_THIRD . '/other_module/models/mymodel.complicated_name', 'simple');
$this->EE->simple->some_function();The following worked for me using Expression Engine’s “add_package_path” function.
Points to third_party/dag_rates folder.
$this->EE->load->add_package_path(PATH_THIRD . 'dag_rates');Load the model from this new path.
$this->EE->load->model('rates_model');Model functions can now be used as follow.
$this->EE->rates_model->my_function()Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.