3

I need to display a module in administrator side by getting the module using it's module position (see the code below). I am having error & doubt is using the code:

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

This JDocumentRenderer is not working in Joomla latest version 3.x. I also referred the link:

JDocumentRenderer does not extend JObject anymore. You must not use any of JObject's methods

But I need to render the module...

$modules = JModuleHelper::getModules("dashboard_main");
$document   = JFactory::getDocument();
$renderer   = $document->loadRenderer('module');
$attribs    = array();
$attribs['style'] = 'xhtml';

foreach($modules as $mod){

   // this code is not rendering the module
   echo $renderer->render($mod, $attribs);
 }
8

Instead of JDocumentRenderer you should use JModuleHelper to render modules:

foreach($modules as $mod)
{
   echo JModuleHelper::renderModule($mod, $attribs);
}

See renderModule() method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.