JModuleHelper/getModules
From Joomla! Documentation
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
)
)