Webeks.net - freelance programming
freelance programming - php, Joomla, Zend ...
Home :: Articles :: Programming :: Joomla! :: Joomla module title in custom template

Joomla module title in custom template

Written by Miha

I've spent last hour finding out why module titles don't show in my custom build template for Joomla 1.6. I was going trough modules source and didn't find any line that would display modules title. However titles did show on all of core templates. Strange :)

Joomla has a possibility to override default html output. You can put this in html folder under your templates folder. I know that I can make overrides for components and also a single module. But didn't know that there is a possibility to add and control all modules display with a style parameter. This article in Joomla docs is a good reference point.

 

Joomla chrome module

Module chrome allows template designers to have a certain amount of control over the way the output from a module is displayed in their template. Essentially, it consists of a small amount of predefined HTML which is inserted before, after, or around the output from each module, and which can then be styled using CSS.

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:

  1. function modChrome_STYLE( $module, &$params, &$attribs )
  2. {
  3. /* chromed Module output goes here */
  4. }

Within this function you can make use of any of the available Module properties (i.e. the fields in the jos_modules table).

  1. function modChrome_webeks( $module, &$params, &$attribs )<br style="padding: 0px; margin: 0px;" />{
  2. if ($module->showtitle) {
  3. echo '<h2>' .$module->title .'</h2>';
  4. }
  5. }

Module chrome is determined by using the 'style' attribute in the statement calling the module. For example, the following statement may be used in the index.php file of a template to insert the Modules in the 'user1' position and apply the 'webeks' module chrome:

  1. <jdoc:include type="modules" name="user1" style="webeks" />


blog comments powered by Disqus