API16

JDocumentRendererModule/render

From Joomla! Documentation

< API16:JDocumentRendererModule
Revision as of 17:42, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Renders a module script and returns the results as a string <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JDocumentRendererModule...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Renders a module script and returns the results as a string

[Edit Descripton]

Template:Description:JDocumentRendererModule/render

Syntax[edit]

render($module, $params=array(), $content=null)
Parameter Name Default Value Description
$module $name The name of the module to render
$params array() $params Associative array of values
$content null

Returns[edit]

string The output of the script

Defined in[edit]

libraries/joomla/document/html/renderer/module.php

Importing[edit]

jimport( 'joomla.document.html.renderer.module' );

Source Body[edit]

public function render($module, $params = array(), $content = null)
{
        if (!is_object($module))
        {
                $title  = isset($params['title']) ? $params['title'] : null;

                $module = &JModuleHelper::getModule($module, $title);

                if (!is_object($module))
                {
                        if (is_null($content)) {
                                return '';
                        }
                        else {
                                $tmp = $module;
                                $module = new stdClass();
                                $module->params = null;
                                $module->module = $tmp;
                                $module->id = 0;
                                $module->user = 0;
                        }
                }
        }

        // get the user and configuration object
        $user = &JFactory::getUser();
        $conf = &JFactory::getConfig();

        // set the module content
        if (!is_null($content)) {
                $module->content = $content;
        }

        //get module parameters
        $mod_params = new JParameter($module->params);

        $contents = '';
        if ($mod_params->get('cache', 0) && $conf->getValue('config.caching'))
        {
                $cache = &JFactory::getCache($module->module);
                $cache->setLifeTime($mod_params->get('cache_time', $conf->getValue('config.cachetime') * 60));
                $contents =  $cache->get(array('JModuleHelper', 'renderModule'), array($module, $params), $module->id. $user->get('aid', 0).md5(JRequest::getURI()));
        }
        else {
                $contents = JModuleHelper::renderModule($module, $params);
        }

        return $contents;
}

[Edit See Also] Template:SeeAlso:JDocumentRendererModule/render

Examples[edit]

<CodeExamplesForm />