2

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.

user2767055
  • 49
  • 1
  • 2
  • 7

3 Answers3

2

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

Jobin
  • 8,238
  • 1
  • 33
  • 52
  • You could improve you answer by using json_decode to get the params as object, change some object values and return a new encoded json object to the model params. – Dennis Heiden Feb 22 '16 at 13:41
1

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 );
Lodder
  • 19,758
  • 10
  • 59
  • 100
0

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); 
Pritesh Mahajan
  • 4,974
  • 8
  • 39
  • 64