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 comments

  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!

  2. I am thinking of buying a joomla template from template monster and importing it into joomla.

    How hard are they to import? Is it plug and play easy? Or will I need to configure plugins etc.

    Thanks.

  3. adisetiawan · October 5, 2012

    installing template is easy, look for their doc in joomla.org