A consulting company that subcontracts work to us sent us a quick task late at night yesterday. Everytime they create a module on a particular website, the module’s content is encapsulated in the following div:
<div class=”moduletable”>Module Content</div>
The encapsulating div is causing problems in the layout and they want to remove it.
Now, if one does a research on the Internet on this particular issue he’ll find complex solutions that require modifying Joomla’s core or using a plugin instead of a module. This is odd because the solution couldn’t be simpler (and it seems that nobody knows it): the solution consists of simply changing the style (we’re not talking about CSS styles here) of the module in the index.php of the template. Here’s how to do it:
- Connect, through FTP, to the root directory of your Joomla website.
-
Go to the main directory of the template serving your Joomla Website (for example, /templates/mytemplate).
-
Open the index.php file (which is the main template file).
-
Search for the name of the position of the module in question (for example, ad-bottom).
-
Replace the following code:
<jdoc:include type="modules" name="ad-bottom" style="xhtml" />
with:
<jdoc:include type="modules" name="ad-bottom" style="none" />
Note that we are assuming that the position’s name of your module is ad-bottom.
-
That’s it! By replacing xhtml with none we ensured that Joomla no longer encapsulates the module’s content in a
div block.
We always wonder how come these very simple (and very important) tips are badly documented to the point that even on Joomla’s own forums you’ll find half baked complex solutions to the same problem – while the problem can be resolved by just changing one simple word.
Thanks for solving this problem, but what are the other module styles?
There are 6 module styles: none, xhtml, rounded, horz, table, and outline. The first two are the most used. You can read more about them here.
Some of my modules have “raw” as their style? What is that?
raw is the equivalent of none. In fact, raw as a module style doesn’t exist, so Joomla automatically defaults to none when it sees it. The reason why some developers use raw as a style when they’re including modules in the template is because they are accustomed to Joomla’s manifest (xml) files where fields have a raw property.
Now, if some of your modules are giving you some hard time when you’re including them (for example, the formatting is all messed up), then try the above method. If it still doesn’t work for you or if the whole thing is a bit over your head, then please contact us. We are always here for help and we don’t charge much!
Your site has often provided an answer.
Brilliant! Solves my problem and transfers valuable knowledge also. Thank you very much.