What you can learn?
Reading this article will give you:
Layout explained
As you can see from Picture 1, Joomla / Mambo layout looks quite the same as any standardized portal webpages with 5 main parts:
- Top: <pathway>, <user3> and <user4> modules.
- Left: <left> module.
- Center: <banner>, <user1>, <user2> and <mainbody> modules.
- Right: <right> module.
- Bottom: <footer> module.
This is just a default layout, all modules can be placed anywhere defined in the index.php file of the template. The syntax of loading modules PHP code as follows:
mosLoadModules( $position_name [, $style] )
With Joomla 1.0.1 / Mambo 4.5.2 and older versions, we have 0 (default), -1, 1, -2 or -3? for the $style of Joomla / Mambo. In Joomla / Mambo 4.5.2.1 the value "-3" for the $style was introduced. So what are the differences of using 0, -1, 1, -2 or -3? [ see (c) in Picture 1 ]
module Title |
Module output |
Module Title |
Module output |
| |
Module 1 OutputModule 2 OutputModule 3 Output
Module Title
Module output
Module Title
Module output
I myself really like features of the new "-3" style. Using the "-3" will help you to create stylish rounded corners template for Joomla / Mambo. Step-by-step on how to create a rounded module is guided in this tutorial.
Tricks to hide / display modules wisely.
Obliviously in Joomla / Mambo templating, you have to preserve an area for a module to display. This area is often created with a fixed width block using <table, <td> or <div> tags . And the outcome of of this is when the module you desire to display is unpublished, the block you preserve will still be there, creating an ugly blank area and take the space of other contents. Therefore, a simple solution using if {} condition + mosCountModules syntax will be a perfect workaround. [ See (b) in Picture 1 ]
The sample code you see in Picture 1 is a standard one, a more complex if {} will produce a better result and remove unnecessary HTML codes. For example:
0 && mosCountModules( "user2" )>0) {
$numblock = 2;
$blockwidth = 50;
}else if (mosCountModules( "user1" )>0 || mosCountModules( "user2" )>0) {
$numblock = 1;
$blockwidth = 100;
}
?>
0) { ?>
I use above codes in MBT GREY template to organize user1 and user2 modules. Those advanced if {} codes will divide user1 and user2 display areas into 2 equal boxes if both are published [Picture 2]; stretch the box to fit with the main content when one of them is unpublished [Picture 3] and, of course both will be totally removed when they are unpublished.
Though the above tricks can be applied in all modules (especially left, right, top, users), to some standard modules which are often the "must have" modules of a your site like search (user4) , topmenu (user3), pathway (pathway), and mainbody (mosMainBody) then a simple if {} is enough. [ See (a) in Picture 1 ]
Bottom lines.
There are other 2 functions that are quite useful in Joomla / Mambo templates:
or:
Finally, this tutorial is written for Joomla 1.0.1 / Mambo 4.5.2.3 and also true to all versions up to now, Joomla / Mambo is developing everyday and there will be more interesting functions and features for template designers. I will try to keep this article updated.
{mosgoogle center}