In this article I explain how to load a module inside a component or load a module within a HTML override file.

This method is really handy when you want to load a module within a component. Examples of when you want to do load a module within a component include but are not limited to:

  • When you want to load a module underneith the title but before the content
  • When you want to load a module within the metadata

Remember that you probably won't need to use this technique for com_content because you can display a Joomla module within content.

Here is the php code needed to display a module within a component in Joomla 2.5 or (it also works in Joomla 3.0):

$position = 'positionName';
$modules =& JModuleHelper::getModules($position); 
foreach ($modules as $module) { 
  echo JModuleHelper::renderModule($module); 
} 

Note: Tested for Joomla 2.5 to Joomla 3.3

However, if you don't have to support Joomla 2.5, you can just prepare the content:

echo   JHTML::_('content.prepare', '');