Wednesday, 7 August 2013

Joomla Accessing getModules datastructure

Joomla Accessing getModules datastructure

From this
jimport( 'joomla.application.module.helper' );
$modules = JModuleHelper::getModules( 'top' );
echo '<pre>';
print_r( $modules );
echo '</pre>';
which outputs this structure
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] =>
)
)
I currently call this function to get it to output it
<?=$modules[0]->content ?>
I would like to call with one line but it doesnt work
<?=JModuleHelper::getModules( 'top' )[0]->content ?>
I can do it on the singular version of getmodule and it works, it works
because its not wrapped in an array.
<?=JModuleHelper::getModule( 'top' )->content ?>
Anybody know how to drill down on this data structure with one line of code?

No comments:

Post a Comment