Actions

Difference between revisions of "JModuleHelper/renderModule"

From Joomla! Documentation

Line 22: Line 22:
 
This method will return the output html of the module. Language variables (JText::_('Say something');) are being translated. Furthermore the output of the module will be framed by a chrome (See: [[What is module chrome?]]). The default name of the chrome is 'none'.
 
This method will return the output html of the module. Language variables (JText::_('Say something');) are being translated. Furthermore the output of the module will be framed by a chrome (See: [[What is module chrome?]]). The default name of the chrome is 'none'.
 
===Example===
 
===Example===
In the following example we'd like to load the Login module, and put it into the xhtml chrome:
+
In the following example we'd like to load the 'mainmenu' module and particularly, we want to load the module with the title 'Key Concepts'. Furthermore we want to frame the output with the xhtml chrome:
 
<source lang="php">
 
<source lang="php">
 
+
jimport('joomla.application.module.helper');
 +
$module = JModuleHelper::getModule('mainmenu', 'Key Concepts');
 +
$attribs['style'] = 'xhtml';
 +
echo JModuleHelper::renderModule($module, $attribs);
 +
/* OUTPUT HTML:
 +
<div class="moduletable_menu">
 +
    <h3>Key Concepts</h3>
 +
    <ul class="menu">
 +
        <li class="item40"><a href="/mysnugs/extensions"><span>Extensions</span></a></li>
 +
        <li class="item38"><a href="/mysnugs/content-layouts"><span>Content Layouts</span></a></li>
 +
        <li class="item43"><a href="/mysnugs/example-pages"><span>Example Pages</span></a></li>
 +
    </ul>
 +
</div>
 +
*/
 
</source>
 
</source>
  

Revision as of 10:08, 7 November 2008

Contents

Syntax

void renderModule ( $module, [ $attribs = array()])

where:

Argument Data type Description Default
$module Object The module object see JModuleHelper/getModule
$attribs Array $attirbs['style'] defines which chrome will frame the output of the module. See: What is module chrome?

What does this method do?

This method will return the output html of the module. Language variables (JText::_('Say something');) are being translated. Furthermore the output of the module will be framed by a chrome (See: What is module chrome?). The default name of the chrome is 'none'.

Example

In the following example we'd like to load the 'mainmenu' module and particularly, we want to load the module with the title 'Key Concepts'. Furthermore we want to 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);
/* OUTPUT HTML:
<div class="moduletable_menu">
    <h3>Key Concepts</h3>
    <ul class="menu">
         <li class="item40"><a href="/mysnugs/extensions"><span>Extensions</span></a></li>
         <li class="item38"><a href="/mysnugs/content-layouts"><span>Content Layouts</span></a></li>
         <li class="item43"><a href="/mysnugs/example-pages"><span>Example Pages</span></a></li>
     </ul>
</div>
*/

See also