Can i display a Joomla module using PHP? What would be the script
to achieve this? (If it's possible!)
1 Answer
Try this,
Did you mean to render the module output using a PHP script? In which case, then take a look at this:
For older versions < Joomla3.x
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$module = JModuleHelper::getModule('mod_fmDataGrid');
$params = "param1=bruno\n\rparam2=chris";
$module->params = $params;
echo $renderer->render($module);
For latest version. Joomla3.x
$modules = JModuleHelper::getModules("dashboard_main");
$document = JFactory::getDocument();
$attribs = array();
$attribs['style'] = 'xhtml';
foreach ($modules as $mod)
{
echo JModuleHelper::renderModule($mod, $attribs);
}
Hope this helps.
-
-
Pass the module name like "mod_fmDataGrid" or "dashboard_main", If you need to pass its param too then check params and attrb options– JobinCommented May 29, 2014 at 6:38
-
3I think creating the
$renderer
variable is unnecessary since you're not using it anywhere in the code?– EjazCommented Jan 20, 2016 at 3:02