Logo of SermonSpeaker Extension Claim

Login Form

Since Sermonspeaker 4.3, custom layouts are supported. This article will explain how you can create your own layout and share it with other users.

Some basics about Joomlas "MVC" system

Joomla uses a system named "MVC" (Model, View, Controller) for their code. In easy words that means that the script for a single page is divided into multiple small files of code. One of this file is the controller, which will be responsible for every possible task. Like uploading a file, or displaying a page. You can ignore the controller completely, SermonSpeaker takes care of this. In case the browser requests a page to display, the controller will call the view. In our case this views are located in /components/com_sermonspeaker/views/. If you have a look at the structure of SermonSpeaker you will notice the various subfolders there

When you created your first own layouts, you may have noticed some helper functions. I want to explain those a bit here:

SermonspeakerHelperPlayer

The most important helper function is the player helper. It will take care of the Flash player for you creating all the needed javascript and html calls. The code is located in

/components/com_sermonspeaker/helpers/player.php

The easiest call is to just use

$player = SermonspeakerHelperSermonspeaker->getPlayer($this->items);

This will create a "$player" object containing all the needed code.

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.