Skip to content

Using Module Positions for More Than One Module

In this tutorial we will look at how to reuse module positions for for more than one module and how to have them display conditionally.

Some templates have loads of module positions for displaying different modules on different pages. Often, this is unnecessary and a smaller, cleaner template file can be achieved by creative use of module positioning.

If you want to display a module on the frontpage but do not want this to display anywhere else on your site, you can do this by using:

 <?php if ($option == "com_frontpage") { ?>
      content such as divs etc
 } ?> 

Example:

<?php if ($option == "com_frontpage") {  mosLoadModules('frontpage_position'); } ?> 

- where frontpage position is the module position you want to show only on the front page.

You can even reuse the same module position by specifying a module to load on the frontpage and a different module to load into the same space for your other pages.

Example:

<?php if ($option == "com_frontpage") {
   mosLoadModules('frontpage_position');
   } else {
   mosLoadModules('other_position'); } ?> 

If you enjoyed this post, make sure you subscribe to my RSS feed!

Topic: Mambo Tutorials
Tagged as: Mambo, modules, templates

Share on FriendFeed

{ 0 comments… be the first to comment }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Any comments that look like spam will be treated as spam - this includes SEO titles and use of spurious keywords.

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.