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.

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.”


Call Joomla module in a component

Generally modules are call by its position in Joomla. In template file we define positions for module then active module in backend and set the position for display. But if you want to display a module in a component then following code will be helpful.

We can add a joomla module in a component by it’s position and name.
Continue reading “Call Joomla module in a component”