How to create a module position

Sections:
1. How to create a regular module position in Joomla! 1.5
2. How to create a hidden module position in Joomla! 1.5
3. Hidden module positions in a BonusThemes.com template
4. Why would I ever need a hidden module position?

 

1. How to create a regular module position in Joomla! 1.5

The process is not that complicated. You must choose a name for your new position, add it in the XML file of the template and add some HTML in the main template file.

Let's say your new position will be called my_position .

Edit the XML file of your template. The path of this file is /templates/<your template>/templateDetails.xml. Locate the section positions and add the name of your new position with the same layout as the rest.

The position section should now look like this:

<positions>
      ... existing positions ...
      <position>my_position</position>
</positions>

Now lets add the necessary HTML in the main template file. The path of this file is /templates/<your template>/index.php. You can add the HTML code anywhere inside the body tags. The recommended place is to add it right before the body tag closes, which is at the bottom of that file. So go down the file and look for </body> . We will be adding our HTML right before this closing tag.

The HTML should now look like this:

<jdoc:include type="modules" name="my_position" style="xhtml" />

</body>

Thats it! Now go to the Module Manager and you should be able to see my_position in the positions listing.

In some cases it is useful to have an ID or a class name for your new position. CSS files and JavaScript scripts may need this information in order to identify your position. You can add some more HTML to add this feature:

<div id="my_position_id" class="my_position_class">
      <jdoc:include type="modules" name="my_position" style="xhtml" />
</div>

</body>

 

2. How to create a hidden module position in Joomla! 1.5

If you need a hidden position you can follow the exact steps mentioned above, with one more addition to the wrapper <div> of the position. The trick is to set the CSS element display to the value "none":

<div style="display:none">
      <jdoc:include type="modules" name="my_position" style="xhtml" />
</div>

</body>

 

3. Hidden module positions in a BonusThemes.com template

The latest templates from Bonus Themes already include five hidden module positions. Their names are aux1, aux2 .. aux5. The template framework used by Bonus Themes has its own way to assign IDs and CSS classes to any positions, and that is by using the prefix "pos_". So the ID for the hidden module position aux1 is pos_aux1 etc.

 

4. Why would I ever need a hidden module position?

There are types of modules that require dynamic information from your website. Take for example a sliding panels module, or a menu. Both require information from your website, and if there is a way to make that information dynamic instead of using static content, the result would be ideal.

Joomla! has a very well thought way of using modules. Combined with menu items, modules can be easily manipulated across your website from the Module Manager. So, modules can be a very smart way to organize information in different parts of a page.

Hidden module positions can help by making these two thoughts a reality. You publish the modules you want to show in a hidden position, and the dynamic modules use them as their source to present them with all the animations and effects that create a great experience for the user.