For instance, if I have a position called 'position-1' and I've multiple modules in position-1. How can I get all module names based on position (in this case 'position-1')? Is it even possible? If so, how?
2 Answers
If you mean programatically, JModuleHelper should return the info you need.
$modules = JModuleHelper::getModules('position-1');
print_r($modules);
-
What I get is - img.exs.lv/e/z/ezeliitis/Untitled_4.png Shouldn't I fetch two objects instead of only one?– Poo123Mar 27, 2017 at 11:46
-
It should return an array of all the modules in that position. I've tested it both on a template and a module. Curious that the object it returns for you has an ID of 0 when they usually start at 1? Are you creating/assigning modules via the module manager?– RichardBMar 27, 2017 at 11:55
-
No, I do it like this: <jdoc:include type="modules" name="position-3" style="xhtml" />– Poo123Mar 27, 2017 at 12:08
-
How are you assigning modules to that position, though? You seem to have a module position and a module which are both called position-3 - there may just be conflicts in your naming.– RichardBMar 27, 2017 at 12:20
If you wish to know which modules are assigned to a specific template position, simple go to Extensions->Modules, then click Search Tools and then specifie the disired position in the Select Position select box. Hope that's what you are looking for.
-
Not exactly. I want to do it through program code (Using PHP). I have custom template (maybe this makes things clear). I thought Joomla have some way to get module parameters (in this case name/title) of specific position.– Poo123Mar 27, 2017 at 11:28