Call or load any Joomla model to controller, other modules or plugin

Here’s a short version:

first, load model helper

JLoader::import('joomla.application.component.model');

second, import the model, adjust with your own component, first parameter is the filename without .php

JLoader::import( 'renewal', JPATH_ROOT . DS . 'components' . DS . 'com_mymember' . DS . 'models' );

third, create new instance. in this case, the class name is mcsmemberModelRenewal

$renewalmodel = JModel::getInstance( 'renewal', 'mcsmemberModel' );

now you can use the model, ie:

$renewalmodel->someMethod();

happy coding!

3 thoughts on “Call or load any Joomla model to controller, other modules or plugin”

  1. I’m interested in simple and safe way to make Joomla 2.5 website (SQL database, extensions, plugins, everything) and than simply and safe move everything to web host.
    So I need reliable software to make virtual server on my computer make everything, and easy move to web host when I buy it, any suggestions?
    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>