How to import joomla modules inside any custom components

This tutorial will explain how to import joomla modules inside custom components like plugin, module or components. In this tutorial sample code and demo is available.

Before starting the tutorial you have to create one position for your module.

Import Joomla helper in your custom component

First step import the module helper function. find the code below.



Once you imported the above code call your position to include all the mapped modules to display inside custom components. Find the code below.

$modules = JModuleHelper::getModules('relatedArticles'); foreach($modules as $module) {
     echo  "<h3>".$module->title."</h3>"; 
     echo JModuleHelper::renderModule($module);

In the above code you can find the position name “relatedArticles” which is the position I want to add below my article and you can find below with the name “Related Posts You May Like…”

foreach will loop what ever module linked with “relatedArticles” position.

Same you can add you position name and enjoy seeing your modules in any ware you want to place like plugin, components and etc inside Joomla project.

Latest posts by W3TWEAKS (see all)


Leave a Reply

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