From Joomla! Documentation

Revision as of 15:52, 7 February 2009 by Chris Davenport (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This method will return the output HTML of the module. All language variables are translated. The output from the module will be framed by any chrome styles specified. If the '?tp=1' argument is added to the request URL then the 'outline' chrome style will be automatically appended to the end of the chrome style cascade.


string renderModule( $module, $attribs )


Argument Data type Description Default
$module object The module object. This can be obtained by calling JModuleHelper::getModule or JModuleHelper::getModules.
$attribs array An optional array of attributes. See note below. This array will be passed to the module chrome code.

The $attribs array is passed in its entirety to the module chrome code. Since this method will generally be called during processing of a <jdoc:include ... /> tag in the template, this array is typically expected to contain:

Element Description
name The name of the module.
style Defines which chrome(s) will frame the output of the module. This will be a space-separated string of module chrome style names. If no 'style' attribute is specified then the 'none' chrome style is used, which just outputs the raw HTML from the module.

Other attributes may also be required by specific module chrome styles.


Render the 'mod_mainmenu' module with the title 'Key Concepts'. Frame the output with the 'xhtml' chrome:

jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule( 'mainmenu', 'Key Concepts' );
$attribs['style'] = 'xhtml';
echo JModuleHelper::renderModule( $module, $attribs );

which will output:

<div class="moduletable_menu">
    <h3>Key Concepts</h3>
    <ul class="menu">
         <li class="item40"><a href="/extensions"><span>Extensions</span></a></li>
         <li class="item38"><a href="/content-layouts"><span>Content Layouts</span></a></li>
         <li class="item43"><a href="/example-pages"><span>Example Pages</span></a></li>

See also