0
votes

I've seen alot of examples of how to include modules on a custom joomla! component using JModuleHelper::getModules, however, when trying to include modules in a custom position, the array come back empty. Here's my code in my component's template:

<?php
jimport('joomla.application.module.helper');
$modules = JModuleHelper::getModules('comwhcustomer'); 
foreach ($modules as $module){
   echo JModuleHelper::renderModule($module);
}
?>

You'll notice the position I'm passing the getModules function is comwhcustomer. This code is returning a blank array. If I pass "footer", I do successfully get the module in the footer position.

I'm using an adapted protostar tempalte and I have added the comwhcustomer position to the xml definition file for the template. I've created the module in module manager and in the position filed, I've selected the "comwhcustomer" position that shows up in the dropdown. On the modules manager page, I see the module listed in the position selected (comwhcustomer). I've confirmed in the database table #__modules that the position is saved correctly.

However, the array is still coming back empty on the getModules call. What am I missing?

Joomla version 3.4.1 Local environment Windows IIS PHP 5.4.24 MySQL db

PS - As an alternative, I have sucessfully loaded the module with JModuleHelper::getModule() however, none of the attributes I define in the module manager come over, because they're not supposed to. I'd like to use the method mentioned above so I can control the module behavior from the manager rather than attributes in the code, because this position will be used in multiple views of this component.

This is my first time posting to SO. I do appreciate the support :-)

1
Just making sure: are you sure that the module is assigned to the page that you're working on? Try to assign it to all the pages and see if you can see it.itoctopus

1 Answers

1
votes

itoctopus, you were exactly right! The module itself was not assigned to any pages, that's the piece I was not taking into consideration! Thank you so much for your help! I set it to display on all pages and it worked!

Of course, it doesn't show up on all the other pages because they do not contain a position called "comwhcustomer" so it is exactly what I was looking for!