How to use

Context Module allows to make other Modules smart, in such way that with Context Rules Modules are allowed to be displayed when a given content is displayed. This allows to display any Joomla! Module only when content of specific Sections, Categories or other Identifiers is displayed.

Publish Context Module to the Template Position where you want the Modules to be controlled. To use Context Module on more than one Template Position, use a copy of it:

Context Module allows to call any of your installed Joomla! Modules on a per rule basis. For that you will need the Module ID of a module, which is shown in the ID column of the module list (see example above).

Context Module is called as all other Joomla! modules and therefore also requires a Menu Assignment. For a start, assign the module to all menu items and use the rules to control when to invoke other modules. For higher granularity in control, you may also assign Context Module (or any instance of it) to a specific menu item.



All settings explained

Context Rules

Here the relations are being set to assign Modules to Sections, Categories, Content Items or Authors. The language describing these rules used here is defined as followed:

Example: Assigning Module with ID 39 to Section with ID 1 & 2

s[1,2]=39

Example: Assigning Module with ID 45 & 46 to Content Items with ID 6 & 7

ci[6,7]=45,46

Example: Assigning Module with ID 19 to all Authors

a[*]=19


The convention for defining these context sensitive rules for Modules is flexible by using this notation:

Convention for definition Context Rules for Modules

s|c|a|ci[*|#,#,#,...]=#
s|c|a|ci[*|#,#,#,...]=#,#,...


These are the abbreviations and their meaning used to described the Context relation:

s   ... Section with ID (or multiple ID's separated by comma) in square brackets.
c   ... Category with ID (or multiple ID's separated by comma) in square brackets.
a   ... Author with ID (or multiple ID's separated by comma) in square brackets.
ci  ... Content Item with ID (or multiple ID's separated by comma) in square brackets.
i   ... Menu Item ID of the current selected menu item.
pi  ... Parent Menu Item ID of the current selected menu item, if the current menu item is linked to a parent menu item.
#   ... The Module ID of the module to be assigned to (shown with) this context rule.


To assign a Module to any of the Sections, Categories, and such use a asterisk (*) instead of ID's in the square brackets:

Single and multiple Modules are allowed to get used with these rules:

=#        ... assigns a single Module with the given ID
=#,#,#,.. ... assigns multiple Modules with the given ID's in order of left to right


  • Multiple ID's are always to be separated by commas.
  • The order of the assignement rules are from top to bottom and left to right


To use a File instead of a Module, use a File Reference:

In addition to using Modules, also PHP script files may get called with these rules. To use this feature, use a File Reference instead of a Module ID:



Then define in the File References the path and file which is referenced to:

File Reference settings to above example

myscript=some/path/to/file/script.php


Combining Rules

Individual Rules are allowed to get AND combined by using & as combining symbol:

Example: Combining Sections with Authors, such that a assigned Module is only used when navigation is in that particular section

s[1,2]&a[5,6,7]=19

This will include the Module with ID 19 only when the current Section is 1 or 2 and the Content Author ID is 5,6 or 7.

Example: Combining Sections with Authors, such that a assigned Module is only used when navigation is in that particular section for all Authors

s[1,2]&a[*]=19

Same as the previous example, instead of limiting to single Author ID's all Authors are selected by using the Asterisk * operator.

See also the Frequently Asked Questions (FAQ) for more examples and hints…

File References

In this area define any File Reference followed by the equal sign ('=') and the real path and filename to the file. The file needs to stay within the Joomla directory structure and be any type of file: Text File, HTML File, PHP-Script. This allows you to include arbitrary files in addition to modules.

Define the File References as per the following structure:

<File Reference>=path/to/file/and/filename.ext

Example for File References

file1=contribution/scripts/somescript.php
myflash=contribution/myflash.html
Only use relative paths, meaning paths that start without a “/”. See the example above…


Custom ID Rules

(Commercial Unlimited License only)

Custom ID's allows any URL GET, POST or Cookie Value used by a third party extension to get assigned to an ID Marker used in the Context Rules.

Please refrain from using the ID Markers already being used by Context Module for the Content Contexts. In particular these:
  • id … carries the ID of the current content item
  • Itemid … carries the Menu Item ID of the current content item

The Syntax for Custom ID Rules is a simple assignment of <value>=<marker>. One Custom ID Rule per line, multiple rules are allowed.

ID Rule Syntax

<value>=<marker>

<value> ... is the URL GET, POST or Cookie Value used by the third party extension
<marker> ... is the Marker used for identifying that value in the filenames


Custom Rules for ID's as numbers

Most Components use Integer Numbers for their ID's. For those number based ID's the notation is to assign a <value> & <marker> pair for the ID's that shall get integrated into the file selection:

Example

extID=ex
mapID=map

With above example the following example URL of

index.php?option=com_extension&task=view&Itemid=132&extID=3

assigns the URL parameter extID to the Marker ex, such that it may get used in a Context Rule like this: ex[8,10]=20.

To check your Custom ID Rules, use the Debug Mode to see which values Context Module will retrieve as Custom ID's. All relations are Case-Sensitive.


Custom ID rules when using with IP-Location for Joomla

You may use Context Module in combination with our IP-Location for Joomla Extension, to introduce Location based rules:

To use Location data for Country and/or City with Context Module use:

Custom ID Rule

modules/mod_contextmodule_ce/plugins/iplocation_city.php=city
modules/mod_contextmodule_ce/plugins/iplocation_country.php=country



City Names are to be Lower Case, Country Codes are used for Countries and these are also Lower Case. Spaces in City Names are replaced by a “hyphen”.

Example Context Rules for Cities and Countries

city[linz]=18
country[at,de]=29


You may need to upgrade to the Commercial Unlimmited License of Context Module, or update your existing Commercial Unlimited License to the Plugin for this Custom ID Rule.



Custom ID rules for other 3rd Party Extensions

Module Filter

Context Module will look for the Module ID and then call the associated module. Context Module itself does not output any code. With the Module Filter you may control if Context Module shall adhere to a modules published state, or not. The options are therefore:

  • Disregard published state of modules: Will call every module once its rule is passed, disregarding its published state.
  • Only show published modules: Will call only a module that is also published once its rule is passed.


Module Output Style

Allows to set the style in which the called modules output shall be generated, set the desired HTML output that will be applied to the output of the modules controlled by the Context Module.
See also embedding the Module for use in Template Files and influencing the Joomla! Wrapping behaviour.

Debug Mode

With 'Show debug information' the module will show information on the Content Context, modules called, files missing to file references and more. Use this to see if rules are passed, to find the Content Context for a particular situation or as help in support issues.

In normal operation, this option may stay at 'No debug information'.