We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Is it possible to load models from another third party module

Development and Programming

Electric Putty's avatar
Electric Putty
88 posts
15 years ago
Electric Putty's avatar Electric Putty

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 works

Any advice would be a great help.

Many thanks,

Malcolm

       
Chuck Liddell's avatar
Chuck Liddell
57 posts
15 years ago
Chuck Liddell's avatar Chuck Liddell

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();
       
williamcarswell's avatar
williamcarswell
1 posts
about 13 years ago
williamcarswell's avatar williamcarswell

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()
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.