Skip to content

dart-creations.com

Advertisement
Home arrow Joomla arrow Joomla Tutorials arrow Understanding Joomla Template Positions

Print E-mail

Understanding Joomla Template Positions

Article Audience: Webmasters / Joomla Newbies

New users of Joomla tend to find template module positions confusing and possibly frustrating. This is because by default you get a large number of module positions however, when modules are assigned to these positions the modules are not shown. This article will attempt to clear the air about template module positions.

Module Positions

In the Joomla (1.0.x) administration site if you go to Site > Template Manager > Module Positions you will find a large list of module positions. These positions are then automatically read and then will be available when assiging a position to a module in Modules > Site Modules.

However, just by having a large number of entries on your Module Positions page, does not automatically mean that you have these positions available in you pages. This is because it is your template which determines the positions available. To be able to use a position you must have something similar to the following in your template's source code

<?php mosLoadModules ( 'center', -1 ); ?> (where center is the position)

This means that any modules which are assigned to the center position will be rendered instead of that code in the template. Thus to know which modules are available for your use, you either need to read the documentation of your template, or else open the files of the template and check which positions are available with the template.

The best thing to do is remove any positions not available from the Module Positions entries not to mix yourself up when assigning positions to your modules. If you require additional template positions, you would need to change your template to cater for the additional positions you need. Obviously, this requires knowledge of PHP and HTML in order not to break your template.

Also note that you can usually add more than one module to the same position i.e. you can add more than one modules to your left and right positions, with the order in which they are displayed being determined by the Order parameter in the Module setup.

Also note that in some poorly written templates the module positions do not agree exactly with the name given to the position (e.g. user position shows up at the bottom). It is up to the author of the template and the Joomla webmaster to understand where the module will be rendered by testing different module positions, and if necessary changing the name in the template code. Please be sure that you always take backups and know exactly what you are doing before changing any template files.

Adding Module Positions

In this section I will show briefly how to create an new module position in the standard template.

Determine where you are going to place the position in your template. You need to understand exactly how the tempalate works. For example we will be adding an adlinks position to my template (to insert Google AdSense adlinks code). We find the position where we want to add the adlinks and insert php / html code similar to the following:

<!-- BEGIN: adlinks -->
  <div id="adlinks" >

   <div class="adlinks-class">
    <?php mosLoadModules ( 'adlinks', -1 ); ?>
   </div>
   

  </div>
  <!-- END: adlinks --> 

We then need to create the Module Position in Site > Template Manager > Module Positions by creating a new adlinks entry

Create a new position in the Module Positions

Once this is done, we can now assign a module to this position in the Modules > Site Modules page.

Assign the new position to a module

The end result is a new available module position in your template.

The Easy Way Out

To create professional layouts quickly and easily, we highly recommend iJoomla Magazine . Whether you need to create an online magazine or just want to make Joomla a lot more powerful and useful, iJoomla Magazine is the ultimate solution. Go and take a look at it , we're sure you won't be sorry!

Do you like this article? Vote for it on JoomlaWire! JoomlaWire It!

 

Comments
Add NewSearchRSS
jansie - thanks for this IP:41.206.160.2 | 2007-07-09 02:37:44
this seems to be the best description of joomla module positioning yet.
Deepak Bhakoo - Wonderfulllllllll :) IP:203.145.128.6 | 2007-07-14 02:25:57
Yes i agree with Jansie. This is simply cool. And i understood so easily. I have learnt how to work with readymade things with Joomla :D but this has taught me really well that how i can extend my knowledge with it. Currently working on my site todaysfunda.com and this tutotial really has helped me figure out things with it. Thanks again :)
bilal - bad example IP:198.54.202.218 | 2007-07-26 06:21:55
pay attention to your site!, i cant read the article because the modules on the right are overlapping onto the content..... please advise/ sort out

Thanx
DART Creations - Problem Fixed IP:217.145.5.18 | 2007-07-26 07:34:10
We have a wide layout resolution, so we tend to forget that other people have lower resolutions. Please excuse the oversight.
luo - GOOD IP:91.127.117.221 | 2007-08-17 02:50:03
I think,that this is really good instructions to add some new module to the joomla CMS.
Thank you..
Kristie - Thanks IP:75.71.158.215 | 2007-08-25 09:45:25
This is a great explanation. I've been wondering about this, and I'm off to go try it!
Dan - I'm still missing some fundam IP:72.230.84.48 | 2007-09-14 03:11:19
I guess I just don't understand what part of that code "positions" the module. For example. What if you want to create a bottom module, or move a module? That's what I'm looking for and I can't seem to understand it.
DART Creations - Mdoule positions - response to IP:217.145.5.18 | 2007-09-14 04:52:09
Dan,

when creating / modifying a template position, you need to change the index.php of the template (template//inde.php. This php file is the file which is used to create the "look" of the page, i.e. where a position will be loaded. This is determined by normal HTML / CSS positioning rules. E.g. if you want to create a bottom module, you need to change the HTML of the index.php such that you create a new placeholder (using divs or otherwise) in the page. This would then be replaced by the such that the modules assigned to positionxx are loaded in place of the modLoadModules statement.
nirav - Gr8 IP:61.17.14.151 | 2007-09-20 06:21:24
The best article i found in this context !!!!!!!
sing1ejack - dimensions IP:71.168.86.191 | 2007-09-28 07:48:41
So what defines the dimensions of the space that a module occupies? The module itself? Or is it specified a template file?
DART Creations - dimensions IP:85.232.195.229 | 2007-09-28 11:13:11
sing1ejack,

the space occupied by the modules should be defined the CSS styles which the modules is using. This means that, the template will not be "hard-coding" the size and ensure that either the module, or the CSS styles of the template determine the size that is occupied.
mike - for 1.5? IP:72.48.234.54 | 2007-10-02 12:50:19
Hello,
I'm curious, has this format changed in any way for 1.5?

I notice the presence of alot of these types of entries now:



where jdoc seems to have replaced the mosloadmodules and the position seems to be defined by 'name="right"'

Is this accurate?

Thank you for this overview... I, too, was confused as to the usage of positions.
mike - for 1.5 - continued IP:72.48.234.54 | 2007-10-02 13:48:02
Oops.. looks like the code was parsed out in my last comment... here's the code without the brackets...

jdoc:include type="modules" name="right" style="xhtml"

Hopefully this will work.
DART Creations - For 1.5 IP:217.169.51.254 | 2007-10-03 00:39:56
Mike, The article above is for 1.0.x, hopefully I will update for 1.5 in the near future.
Bryce - Removing position? IP:72.16.213.154 | 2007-11-08 09:54:01
What if you would like to remove a position altogether, without shifting the other positions. For example on the site I'm working on (www.sounddrywall.com) there is a "Top" position to the right of my logo that is just an empty box. How would I remove/resize that so that the logo spans the whole top instead of just the left side? When I try to delete or resize, it ends up pulling my Main Menu section up to the "Top" position.
Bryce - Removing position IP:72.16.213.154 | 2007-11-08 10:03:35
Edit: looks like my post was deleted, maybe because of URL? I've removed, if so...

What if you would like to remove a position altogether, without shifting the other positions. For example on the site I'm working on there is a "Top" position to the right of my logo that is just an empty box. How would I remove/resize that so that the logo spans the whole top instead of just the left side? When I try to delete or resize, it ends up pulling my Main Menu section up to the "Top" position.
DART Creations - Removing position from rhuk so IP:85.232.195.188 | 2008-01-08 16:14:43
Hi Bryce,

I just researched your problem and wrote a quick article about it: http://www.dart-creations.com/joomla/tutorials/
removing-the-top-position-from-the-rhuk-solarflare-ii-template.html

Please note that your post wasn't deleted. However posts are cached, so sometimes the comments don't show up immediately.

Hope that helps.
Adem - Thanks IP:80.42.200.19 | 2007-12-09 14:48:11
This worked brilliantly with my template. Cheers
dosdawg - Create the Module Position IP:75.176.191.58 | 2007-12-31 23:33:51
ok, good explaination, no doubt, however, when you get to the part of:
"We then need to create the Module Position in Site > Template Manager > Module Positions by creating a new adlinks entry"

and you place your modules name in what would appear to me to be a position of where a module once resided, since there is an assignment between position 26 and 30, thus giving your module the position of 28. so you dont necessarily need to find a position that is not assigned? this is where i lost it at.

i am looking in Site --> Template Manager --> Module Positions on the current theme i am running. I see what appears to be 34 module positions listed. none have a description but there are 34 module names listed. so does this logistically infer that i can have 34 different modules, plus xx number of additional modules if set by the module order in the parameters? cuz i have searched around, and have seen what is a freshly released theme boasting 26 modules. so i am just trying to find out what are the limitations on how many modules you can actually have?
DART Creations - Module Positions - clarificati IP:85.232.195.188 | 2008-01-01 03:40:17
dosdawg,

The module positions is a place to create "logical" positions. This means that they are module placeholders which CAN exists. What actually determines whether they are used or not, is the template you are currently using.

This means, that I can create my adlinks position logically, however, if my template's HTML does not cater for it, nothing will appear in this position (because there is nothing which converts the logical position to the physical positon in the template). This is why the article follows by creating the position in the template's html.

Typically, Joomla comes with about 30 logical positions created, however rhuk_solar_flare_ii, has much less positions than this. So if you assign a module to a position which does not exist, you won't see it rendered.

Therefore, what determines the number of positions you may have, is your template. The Module Positions create a logical placeholder, the template "actuates" this position, by adding the necessary HTML to render the modules assigned to this position.

Hope this helps.
atslash - Still no way to do it in 1.5 IP:69.146.203.89 | 2008-01-07 16:52:15
Still doesnt seem to be a way to create a new module position in joomla 1.5 rc4 or am i missing something?
Bolkin - Module Position size and align IP:24.192.185.48 | 2008-01-30 11:18:08
I followed your guide and I made a bottom module position for my site's template but the module is not aligned with the template, it is going out of the template's design.

How do I change the position size and alignment so it doesn't mess up the template design? Do I have add another code to the template's CSS file to do this? If so, could you please guide me through it. Thanks.
DART Creations - Bolkin IP:85.232.198.75 | 2008-01-30 15:29:57
Bolkin,

in this article I guide you through the concept of what is needed to create a new position. The tutorial however assumes knowledge of CSS and HTML concepts, because ultimately your module will create HTML and if this is not planned, it will break your template. Unfortunately, teaching CSS and HTML is out of the scope of the tutorials provided here, however there are thousands of pages out there which can help you with this.
bob - thank you IP:79.185.147.80 | 2008-02-08 17:18:39
Until recently I've been using wordpress and I considered myself pretty good at it.

But joomla is completely different and the documentation is so horrible. It leaves out the basics while elaborating on unimportant things...

This short article helped me a lot.
David K - -1 ? IP:66.188.196.224 | 2008-04-03 19:06:09
This was an excellent tutorial. Completely explained what I haven't understood for months.
BUT what does the "-1" mean? In my template that I am using - there are -2's and -3's...
Thanks.
- DK
Tiger - the -1s and 2-s IP:80.176.134.68 | 2008-04-14 05:53:48
The -2 and -1 in the template tells joomla what format to display a given module

i.e 0 i believe means the table will be displayed in tables

-2 means it will be displayed using divs
Ariel - Thank you - it helps me a lot IP:122.3.172.24 | 2008-04-29 23:21:10
I just successfully added a user defined module using the code above and play around a little bit and there ya goes!

Thanks a lot
Ariel - By the way.. IP:122.3.172.24 | 2008-04-29 23:22:24
By the way, I use a few rocket theme templates and it works :)
Juice - collapsible module positions2 IP:24.215.166.192 | 2008-05-13 14:37:45
Seems my code was deleted in my last post. So... if you know of the PHP code to insert to make a module position [div] collapse/dissappear on a page where it is not in use... and where to put this code in the index.php that would be most helpful.
DART Creations - Collapsible module positions IP:217.145.5.18 | 2008-05-13 23:36:06
The best is to check whether there are modules assigned to the position, and using PHP only render that position if there are positions assigned to it:

if (mosCountModules('right') (Not sure about the 1.5 equivalent)

Make sure you are using the correct php syntax.
Write comment
Name:
Title:
Security Image
 

Subscribe to our feed


RSS Feed

DART Creations - Joomla Tutorials, Tips and Tricks and more...

Joomla Tips

DART Creations Joomla Tips, Tricks, tutorials and general Joomla help

Sponsors

Buy us a beer!

Lots of time and effort goes into creating and maintaining this site. If we've helped you, consider buying a beer. It will inspire us to keep on giving! Thanks! (€3)






Cheers ;)