Actions

Difference between revisions of "JModuleHelper/renderModule"

From Joomla! Documentation

(New page: ===Syntax=== ''void'' renderModule ( $module, [ $attribs = array()]) where: {| class="wikitable" !Argument !Data type !Description !Default |- |$module |Object |The module object see [...)
 
Line 19: Line 19:
 
|
 
|
 
|}
 
|}
 +
=== 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===
 
===Example===
To get an installed Module, you can use the following example. This way the method checks if the module has been published, if the module is supposed to be displayed in this page, and if the user meets the access level expectations:
+
In the following example we'd like to load the Login module, and put it into the xhtml chrome:
 
<source lang="php">
 
<source lang="php">
jimport('joomla.application.module.helper');
+
 
$module = JModuleHelper::getModule('login');
+
echo '<pre>';
+
print_r($module);
+
echo '</pre>';
+
/* RESULT:
+
stdClass Object
+
(
+
    [id] => 18
+
    [title] => Login Form
+
    [module] => mod_login
+
    [position] => left
+
    [content] =>
+
    [showtitle] => 1
+
    [control] =>
+
    [params] => cache=0
+
                moduleclass_sfx=_login
+
                pretext=
+
                posttext=
+
                login=
+
                logout=
+
                greeting=1
+
                name=1
+
                usesecure=0
+
    [user] => 0
+
    [name] => login
+
    [style] =>
+
)
+
*/
+
 
</source>
 
</source>
You can also call for a custom module, that has not been installed via the Joomla Backend. $name has start with "mod_" in this case. The method then returns a standard object. It doesn't check if the module is published or not, it doesn't check if the user has the neccessary rights to see the module.
 
  
<source lang="php">
 
jimport('joomla.application.module.helper');
 
$module = JModuleHelper::getModule('mod_examplemodule');
 
echo '<pre>';
 
print_r($module);
 
echo '</pre>';
 
/*RESULT:
 
stdClass Object
 
(
 
    [id] => 0
 
    [title] =>
 
    [module] => mod_examplemodule
 
    [position] =>
 
    [content] =>
 
    [showtitle] => 0
 
    [control] =>
 
    [params] =>
 
    [user] => 0
 
)
 
*/
 
</source>
 
 
===See also===
 
===See also===
* [[JModuleHelper/renderModule]]
+
* [[JModuleHelper/getModule]]
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JModuleHelper]]</noinclude>
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JModuleHelper]]</noinclude>

Revision as of 09:59, 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 Login module, and put it into the xhtml chrome:

 

See also