How to use Joomla Model function into a module or plugin ?


You can use Joomla model function into a module/plugin or another joomla extension using following code. Following example shows us how to show a joomla article in a custom extension.

jimport('joomla.application.component.model');
JModel::addIncludePath(JPATH_SITE . '/components/com_content/models');
$Model = JModel::getInstance('Article', 'ContentModel');
$articleId = '1'; //We used here '1' article id
$article = $Model->getItem($articleId);
echo $article->introtext;

Output : [ article content will print ]

“Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type.”

Advertisements

1 thought on “How to use Joomla Model function into a module or plugin ?”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s