In this article I will try to collect some nice tricks I stumbled about while coding SermonSpeaker

Loading modules into a layout

Sometimes you like to show a module only on specific pages and maybe even in the content itself. There are multiple ways to achieve this:

While usually the site template is responsible for the various module positions, a component can add such positions to its own output as well. The code to do this can be put into any layout file like this:

<?php jimport('joomla.application.module.helper');
$modules = JModuleHelper::getModules('sermonspeaker');
foreach($modules as $module):
  echo JModuleHelper::renderModule($module);
endforeach; ?>

This will load all modules set to the position "sermonspeaker" and render their output. The position can of course be named like you want.

To apply a specific chrome to the module, you can add a parameter array to the renderModule() function:

   echo JModuleHelper::renderModule($module, array('style'=>'chrome-name'));

The available chromes depend on the active template. Read more about module chromes in the official Joomla docs.

Alternative Layouts

Joomla has some layout tricks implemented itself. One thing is that you can override each layout in your template, another thing is that you can actually create alternative layouts at the same place. It's kind of the same thing we do in SermonSpeaker, but in the template. There is a nice tutorial about this on magazine.joomla.org.