Skip to content
Johan Janssens edited this page Jun 9, 2019 · 29 revisions

Joomlatools Pages has build in support for Joomla Modules, with Pages modules no longer need to instantiate and managed through the Joomla Module Manager.

Pages can create custom module positions, allows to dynamically inject content into any module position and can instantiate installed modules on the fly, passing in module parameters.

Table of Contents

Injecting in a module position

You can either create a "virtual" module and inject the content into the position you specify, or you can define a module name (which needs to exist in Joomla) and instantiate the module. The position to inject in can either be a position defined by your template or a custom position.

Creating a virtual module

To create a module use the following syntax:

<ktml:module position="[position]">
   [content]
</ktml:module>

where [position] is the name of the position and [content] is the content to be inserted.

Instantiating a Joomla module

To instantiate an installed Joomla module use the following syntax:

<ktml:module position="[position]" name="[module]">

where [position] is the name of the position and [name] is the module name to be created.

Specifying Parameters

The <ktml:module> syntax allows to define additional module parameters as xml-style attributes.

Prepend

By default modules are prepended to to the modules in position, to append a module add the prepend attribute and set it to FALSE. For example:

<ktml:module position="[position]" name="[module]" prepend="false">

Style

The module chrome can be defined through the style attribute.

<ktml:module position="[position]" name="[module]" style="[style]"> 

Style can be a comma separate list of different chromes, the module will be wrapped in FIFO order, meaning that the first defined style becomes the inner wrapper, and the last defined style the outer wrapper.

Note: If the modules position has it's own style defined the module style will override this for this specific module.

Custom

Module parameters can be defined as custom attributes, for example:

<ktml:module position="sidebar" name="menu" title="Side Menu" class="sidemenu" startlevel="1" endlevel="3">

Defining module positions

To define a module position use the following syntax:

<html:modules position="[position]" condition="[condition]">

where [position] is the name of the position and [condition] is an optional condition. Only if the condition evaluates to TRUE the modules will be rendered.

Using conditions

A condition uses position names and supports following logic operators: + | - | * | / | == | != | <> | < | > | <= | >= | and | or | xor.

For example

<html:modules position="sidebar" condition="sidebar >=2 and menubar != 0">

Will only render the sidebar modules if there are at least 2 modules injected in the position and the menu position is not empty.

Wrapping modules

If you want to wrap the modules inside a html element to apply additional styling you can for example do the following:

<khtml:modules position="sidebar" condition="sidebar >= 2">
<div class="modules">   
   <ktml:modules:content>
</div>
</ktml:modules>

The <ktml:modules:content>element will be replaced with the modules, and it allows you to wrap the modules with additional html that only be rendered if the sidebar contains at least two modules.

Position parameters

The <ktml:module>syntax allows to define additional position parameters as xml-style attributes.

Style

The module chrome can be defined through the style attribute.

<ktml:modules position="[position]" style="[style]"> 

Style can be a comma separate list of different chromes, the module will be wrapped in FIFO order, meaning that the first defined style becomes the inner wrapper, and the last defined style the outer wrapper.

Note: If an individual module in the position has it's own style defined the modules style will not be applied.

Custom

Custom module position attributes are passed to the onRenderModule and onAfterRenderModule events and can be used by plugins. For more information please refer to the plugin documentation of the specific module plugin for more information what parameters they support.

Clone this wiki locally