Back to ModulesRenderer class

Method render

public string
render
(mixed $position, mixed $params = array(), mixed $content = null)
Renders multiple modules script and returns the results as a string
Parameters
  • string $position The position of the modules to render
  • array $params Associative array of values
  • string $content Module content
Returns
  • string The output of the script
Since
  • 3.5

Method render - Source code

/**
 * Renders multiple modules script and returns the results as a string
 *
 * @param   string  $position  The position of the modules to render
 * @param   array   $params    Associative array of values
 * @param   string  $content   Module content
 *
 * @return  string  The output of the script
 *
 * @since   3.5
 */
public function render($position, $params = array(), $content = null)
{
    $renderer = $this->_doc->loadRenderer('module');
    $buffer = '';
    $app = Factory::getApplication();
    $user = Factory::getUser();
    $frontediting = $app->isClient('site') && $app->get('frontediting', 1) && !$user->guest;
    $menusEditing = $app->get('frontediting', 1) == 2 && $user->authorise('core.edit', 'com_menus');
    foreach (ModuleHelper::getModules($position) as $mod) {
        $moduleHtml = $renderer->render($mod, $params, $content);
        if ($frontediting && trim($moduleHtml) != '' && $user->authorise('module.edit.frontend', 'com_modules.module.' . $mod->id)) {
            $displayData = array('moduleHtml' => &$moduleHtml, 'module' => $mod, 'position' => $position, 'menusediting' => $menusEditing);
            LayoutHelper::render('joomla.edit.frontediting_modules', $displayData);
        }
        $buffer .= $moduleHtml;
    }
    $app->triggerEvent('onAfterRenderModules', array(&$buffer, &$params));
    return $buffer;
}