Friday, February 19, 2010

Standard module chrome styles

From Joomla! Documentation


  • none. Output the raw Module content with no wrapping.
  • table. Output the module in a table.
  • horz. Output the module as a table inside an outer table.
  • xhtml. Output the module wrapped in div tags.
  • rounded. Output the module wrapped in nested div tags to support rounded corners.
  • outline. Output the module wrapped with a preview border.

Applying custom module chrome

From Joomla! Documentation

To define custom Module chrome in your template you need to create a file called modules.php in your template html directory. For example, this might be PATH_TO_JOOMLA/templates/TEMPLATE_NAME/html/modules.php.

In this file you should define a function called modChrome_STYLE where 'STYLE' is the name of your custom Module chrome. This function will take three arguments, $module, &$params, and &$attribs, as shown:

<?php 
function modChrome_STYLE( $module, &$params, &$attribs )
{
/* chromed Module output goes here */
}
?>


Custom chrome attributes

It is also possible to pass further attributes into the Module chrome function using the same statement that sets the Module chrome. These additional attributes can be anything you like, and are stored in the $attribs array. Take the following example Module chrome function:

<?php
function modChrome_custom( $module, &$params, &$attribs ) {
if (isset( $attribs['headerLevel'] ))
{
$headerLevel = $attribs['headerLevel'];
} else {
$headerLevel = 3;
}

if (isset( $attribs['background'] ))
{
$background = $attribs['background'];
} else {
$background = 'blue';
}

echo '<div class="' .$params->get( 'moduleclass_sfx' ) .'" >';

if ($module->showtitle)
{
echo '<h' .$headerLevel .'>' .$module->title .'</h' .$headerLevel .'>';
}

echo '<div class="' .$background .'">';
echo $module->content;
echo '</div>';

echo '</div>';
}
?>