Joomla! 1.5 module chrome offers web designers a flexible way to manipulate the output of modules. The built in chrome functions can be found in templates/system/html/modules.php. These functions can be accessed with the <jdoc> tag in your template. For example, the tag <jdoc:include type="modules" name="left" style="xhtml" /> has the style "xhtml", so Joomla! will look for the function modChrome_xhtml(), and use this to generate the output for the module.
You can use these functions as a guide, and make your own chrome. To do this, create a file in your template at templates/YOUR_TEMPLATE_NAME/html/modules.php. Any functions you add to this will be available to use in your template. Just make sure you follow the examples for the naming convention, and to know the variables you have available.
Here's a module chrome I made to give me more flexible module style options. I wanted a way to add numbered css class names to each published module in the given position, and also to easily identify the first and last module in css. This way, no matter what modules may be published, my template can adapt automatically.
Here's the <jdoc> tag I use: <jdoc:include type="modules" name="right" style="count" />
This means that all the modules in the "right" position will refer to the "count" function in my custom module chrome. And here's the corresponding function, that will calculate the information about the modules being displayed, and add appropriate css class names.
*NOTE: You must clear the module cache if you change the order of your modules that use this function, or they will not have the correct css class names assigned. Once the module cache is cleared, it should regenerate the correct css classes.
function modChrome_count($module, &$params, &$attribs)
{
if (!empty ($module->content)) :
$document = &JFactory::getDocument();
static $modulenumber = 1;
$class = $params->get('moduleclass_sfx');
$class .= ' module-number-'.$modulenumber;
if( $modulenumber == 1 ) {
$class .= ' first';
} else if ( $modulenumber == $document->countModules( $attribs['name'] ) ) {
$class .= ' last';
}
$modulenumber++;
?>
<div class="moduletable<?php echo $class; ?>">
<?php if ($module->showtitle != 0) : ?>
<h3><?php echo $module->title; ?></h3>
<?php endif; ?>
<?php echo $module->content; ?>
</div>
<?php endif;
}