2
votes

How do we render module in joomla with the title. Because now, I am able to render the module based on the position but it does not include the module title.

Here's how I render the module.

<?php
jimport('joomla.application.module.helper');
$modules = JModuleHelper::getModules('position-3');
foreach ($modules as $module) {
echo JModuleHelper::renderModule($module->title);
echo JModuleHelper::renderModule($module);
}
?>

Many Thanks.

3

3 Answers

2
votes

Try this,

Using this method you can pass parameters to the module .

 $document = JFactory::getDocument();
 $renderer = $document->loadRenderer('module');

 $Module = JModuleHelper::getModule('mod_fmDataGrid');

 $Params = "param1=bruno\n\rparam2=chris"; //This is the way of passing params values
 $Module->params = $Params;
 echo $renderer->render($Module);

Hope it helps..

1
votes

Try using the following:

foreach ($modules as $module)
{
    echo $module->title;
    echo JModuleHelper::renderModule($module);
}

You can also use the following, however you will have to manually enter the module title. This is only assuming you don't want it to be dynamic. You will also need to change mainmenu

$module = JModuleHelper::getModule( 'mainmenu', 'Module Title Goes Here' );
echo JModuleHelper::renderModule( $module );
0
votes

Try this. Hope this will work for you.

    $document = JFactory::getDocument();
    $renderer = $document->loadRenderer('module');
    $contents = '';
    $db = JFactory::getDBO();
    $db->setQuery("SELECT * FROM `#__modules` WHERE id = 'your module id'");
    $modules = $db->loadObjectList();
    $module = $modules[0];  
    $contents = $renderer->render($module);