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.

A. Call Module by position :

$module_position = 'left';
$moduleContents = '';
//following code get all modules which position is 'left'.
foreach (JModuleHelper::getModules($module_position) as $module) {
$moduleContents .= $renderer->render($module, $params);
}

B. Call Module by name :

$module_Name = 'news'; 
$moduleTitle = 'Latest News';
//following code get all modules which position is 'news'.
$module = JModuleHelper::getModule($module_Name, $moduleTitle);
$content = JModuleHelper::renderModule($module);

Please visit following link if you want to know more about Joomla module
http://docs.joomla.org/Module

Advertisements

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