Actions

API16

JDocumentRendererModule/render

From Joomla! Documentation

< API16:JDocumentRendererModule
Revision as of 00:02, 13 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Renders a module script and returns the results as a string

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

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

string The output of the script

Defined in

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

Importing

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

Source Body

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;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />