Documentation
http://docs.joomla.org/Applying_custom_module_chrome
Within this function you can make use of any of the available Module properties (i.e. the fields in the jos_modules table in the Joomla! database on your server) for that Module, but the main ones you are likely to need are $module->content, $module->showtitle and $module->title. $module->showtitle is a Boolean variable, so is either true (when the Module title should be shown) or false (when it shouldn't be shown). $module->content and $module->title will return the main Module content and the Module title respectively. The function is a normal PHP function and so can use any regular PHP code. One common example is to use an if statement to check the value of $module->showtitle, and then include the title or not accordingly:
<?php if ($module->showtitle) { echo '<h2>' .$module->title .'</h2>'; } ?>
The Module parameters are accessed using the $params object. For example, it is possible to assign a Module class suffix to a Module in the backend of your Joomla! site; this is then stored in the parameters for that Module as moduleclass_sfx. To create a <div> with a class determined by the Module class suffix, you would use:
<div class="<?php echo $params->get( 'moduleclass_sfx' ); ?>"> <!-- div contents --> </div>
1 of 3
11/30/2010 9:05 AM
http://docs.joomla.org/Applying_custom_module_chrome
<?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>'; } ?>
You would then set the values for background and headerLevel in the <jdoc:include /> statement as shown below. If no values are set, the attributes default to 'blue' and '3' respectively. Passing attributes to Module chrome from <jdoc:include /> <jdoc:include /> statement
Output
2 of 3
11/30/2010 9:05 AM
http://docs.joomla.org/Applying_custom_module_chrome
Further information about passing attributes to Module chrome can be found in jtopic:115953. Retrieved from "http://docs.joomla.org/Applying_custom_module_chrome" Categories: Advanced | Modules | Templates | Topics This page was last modified on 24 April 2009, at 02:09. Content is available under Joomla! EDL.
3 of 3
11/30/2010 9:05 AM