Actions

Difference between revisions of "JModuleHelper/getModules"

From Joomla! Documentation

(New page: Returns information about all modules in a given module position. ===Syntax=== ''array'' getModules( $position ) where: {| class="wikitable" !Argument !Data type !Description !Default |- ...)
 
m (Methods may be called statically.)
 
Line 76: Line 76:
 
</pre>
 
</pre>
 
===See also===
 
===See also===
* [http://api.joomla.org/Joomla-Framework/Application/JModuleHelper.html#getModules JModuleHelper->getModules on api.joomla.org]
+
* [http://api.joomla.org/Joomla-Framework/Application/JModuleHelper.html#getModules JModuleHelper::getModules on api.joomla.org]
* [[JModuleHelper/getModule|JDocument->getModule]]
+
* [[JModuleHelper/getModule|JModuleHelper::getModule]]
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JModuleHelper]]</noinclude>
 
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JModuleHelper]]</noinclude>

Latest revision as of 14:55, 7 February 2009

Returns information about all modules in a given module position.

Contents

Syntax

array getModules( $position )

where:

Argument Data type Description Default
$position string The name of a module position.

Example 1

To get information on all modules in the 'top' module position:

jimport( 'joomla.application.module.helper' );
$modules = JModuleHelper::getModules( 'top' );
echo '<pre>';
print_r( $modules );
echo '</pre>';

which will output:

Array
(
    [0] => stdClass Object
        (
            [id] => 25
            [title] => Newsflash
            [module] => mod_newsflash
            [position] => top
            [content] => 
            [showtitle] => 1
            [control] => 
            [params] => catid=3
style=random
items=
moduleclass_sfx=
            [user] => 0
            [name] => newsflash
            [style] => 
        )

)

Example 2

If there are no modules enabled in the given module position then an empty array would normally be returned. However, if the '?tp=1' argument is added to the request URL then a dummy module is returned.

jimport( 'joomla.application.module.helper' );
$modules = JModuleHelper::getModules( 'myposition' );
echo '<pre>';
print_r( $modules );
echo '</pre>';

which will output:

Array
(
    [0] => stdClass Object
        (
            [id] => 0
            [title] => myposition
            [module] => mod_myposition
            [position] => myposition
            [content] => myposition
            [showtitle] => 0
            [control] => 
            [params] => 
            [user] => 0
        )

)

See also