In this example we render the default layout (mod_myextension/tmpl/default.
php) using the getLayoutPath() method:
require(JModuleHelper::getLayoutPath('mod_myextension'));
In this example, we render an alternative layout, aptly named 'alternate' (mod_
myextension/tmpl/alternate.php):
require(JModuleHelper::getLayoutPath('mod_myextension',
'alternate'));
If you create alternative module layouts, you can name them the way you want. The
name of a layout corresponds directly to the name of a template file. For example, the
template file vert.php would be the layout vert.
Chapter 5
[ 125 ]
Unlike in components, in modules we do not create XML metadata files to describe
each layout. Instead, if we want to allow an administrator to select which layout he
or she wants to use, we must add a module parameter and use it accordingly.
This is an example of how we might define a parameter to handle different layouts in
the module XML manifest file (alternatively, we could use a list parameter and manually
define each available layout):
description="Style with which to display the module"
directory="/modules/mod_myextension/tmpl"
default="default" hide_default="1" hide_none="1"
stripext="1" filter="\.
Pages:
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181