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>';
}
?>

Comments

  1. To define custom Module chrome in your template you need to create a file called modules.php in your template html directory.

    PHP Developer India

    ReplyDelete

Post a Comment

Popular posts from this blog

PHP: Date Difference for PHP 5.2

HTML5 video loop src change on end play function

Custom OpenCart 2.3.0.2 theme