Loading a Module Position
The simplest case is to include the modules in a position. This could be a regular position but you would usually create a special module position just for the layout (or set of layouts) you are overriding. Here is the code you would place in your layout override.
loadRenderer('modules');
$options = array('style' => 'xhtml');
$position = 'article-banners';
echo $renderer->render($position, $options, null); ?>
What we are doing here is loading the document, loading the "modules" renderer from from the document, setting the module "style" (raw, xhtml, etc) and then outputing the desired module position.
Loading a position is very convenient because you can use the Joomla administrator to set all your module parameters.
Loading a Single Module
Loading a single module requires a little more thought because you have to define all of the parameters by hand. If you don't, you are at the mercy of whatever the developer has set in the module. The code we use to load a single module is like this:
loadRenderer('module');
$options = array('style' => 'raw');
$module = JModuleHelper::getModule('mod_comments_comments');
$module->params = "heading=2\nlimit=10";
echo $renderer->render($module, $options);
?>
Again we are getting the document but this time we load the "module" render. We set the style in the same way as for loading a module position. Now what we do is use the JModuleHelper to load the actual module by its name (the directory name of the module or the name). This returns a module object. We then set the params property of the module in "ini" format, separating each parameter with the newline character "\n".
| « poprzednia | następna » |
|---|







