Control parameters of other modules on the page

(6 votes, average 4.50 out of 5)

MetaMod 2.0 not only includes/excludes other modules — it can now dynamically control any parameters inside those other modules.

Module Parameters

Every module you create has a number of stored parameters. You create these when you fill in the new/edit form for the module. Here’s an example of a standard “Login module” form:


Every Joomla module has the parameters you see on the left:

  • Module Type (which you can’t change once set)
  • Title
  • Show Title
  • Enabled
  • Position
  • Order
  • Access Level
  • ID
  • Menu Assignment

The parameters on the right are different for every type of module — for the Login module, there are parameters controlling:

  • Caching (whether the module will allow itself to be cached – not a good idea for a login module)
  • Module Class Suffix – a suffix added to the CSS class surrounding the module, allowing you to style this module precisely without affecting others
  • Pre-text and Post-text – text to be displayed above and below the username/password form
  • Login and Logout Redirection pages – drop-downs of all the menu items on all menus on the site. Internally these are help as “Itemids”, the primary key of the Menu Item table.
  • Whether or not to show the greeting (“Hello John Doe”) after you’ve logged in, if the module is still displayed.
  • Whether to show your full name in the greeting, or your username.
  • Whether to redirect to HTTPS for the login form submission.

In a standard Joomla installation, once these parameters are set for a module, they are set. The parameters cannot respond to any other factors on the system, e.g. time/date/GeoIP/exact page/user status etc.

Of course, the module itself may be able to display differently according to these factors, but the crucial point is that there is no dynamic control of module input parameters. The only way to change these is to edit the module and edit the parameters.

This forces many Joomla admins to set up multiple, nearly identical copies of modules, in order to use slightly different modules on different pages of the site.

How MetaMod controls other modules’ parameters

In your MetaMod PHP rule box, you can include instructions that can dynamically control other modules.

In standard MetaMod (not Pro), you can control the parameters of any module that the MetaMod includes.

In MetaMod Pro, you can control ANY module on the page, even if it is not included in the MetaMod!

Here’s an example of this in action. We’ll examine the rule in more detail.

->title("This is the new title")
return 19;

The first step is to tell MetaMod which module you want to control.


From then on you can stack on as many parameter changes as you like, each prepended with "->".

Finally, we "return 19;" to ensure that the module is actually included in the MetaMod. (NB for MetaMod Pro, this step is not always necessary, because the parameter change system can apply to any module on the page, not just ones explicitly included by the MetaMod).

There are two types of parameters you can set. These correspond to the “left side” and “right side” of the module form at the top of the page. The “left side” parameters are identical for all modules, while the “right side” ones are different for every type of module.

instruction notes description
->title( string )
sets the title of the module
->showTitle( boolean )
tells Joomla to display or hide the module title
->showTitle() same as showTitle( true ) tells Joomla to display the module title
->hideTitle() same as showTitle( false ) tells Joomla to hide the module title
->enable( boolean )
enables/disables the module
->enable() same as enable( true ) enables the module if it was disabled
->disable() same as enable( false) disables the module if it was enabled
->position( string )
sets the module position that the module will appear in. Only useful in MetaMod Pro, because standard MetaMod will always include the module into the same module position that the MetaMod is in.
->moduleType( string )
for experts! You can change the type of the module. e.g. "mod_custom" for a custom HTML module, "mod_login" for a Joomla login module, etc.
->accessLevel( string or integer )
changes the access level required for the module to be viewed. You can set it by text or by number. It is case insensitive.

"Public" or 0
"Registered" or 1
"Special" or 2

Note though that you will get more control over which groups can see the module by using standard MetaMod rules to govern whether the module will be included or not.
->setParam ( string, string )
sets any of the "right side" parameters of the module. The first string is the name of the parameter(*) and the second string is the value to which to set it.

(*) see Module Parameter Names and Values, below

Module Parameter Names and Values

Every different type of module has different parameters that can be set, although there are some that are common to all.

The main resource for module parameters is inside the mod_XXXXX.xml file for that module, found in the Joomla folder, in /modules/mod_XXXXX/mod_XXXXX.xml.

Common parameters

These parameters can be set for any module, whether or not there’s an interface for it in the module’s new/edit screen.

  • moduleclass_sfx — the module CSS class suffix
  • cache — whether or not to use the global module cache. 1 = use global, 0 = disable
  • cache_time — the time before module is re-cached, in seconds

Archived Content: mod_archive

  • count — the number of items to display

AV Reloaded: mod_avreloaded

  • header_text
  • mediacode
  • footer_text
  • popup — 0=no, 1=window, 2=lightbox
  • pwidth
  • pheight
  • linktxt

Banners: mod_banners

  • target — 0=parent window, 1=new window with browser navigation, 2=new window without browser navigation
  • count — number of items
  • cid — banner client
  • catid — category id (numeric)
  • tag_search — search by tags, 1=Yes, 2=No
  • ordering — whether to randomise the banners. 0=Sticky,Ordering "random"=Sticky,Randomise
  • header_text
  • footer_text

Breadcrumbs: mod_breadcrumbs

  • showHome — 0=No, 1=Yes
  • homeText
  • showLast — 0=No, 1=Yes

Feed Display: mod_feed

  • rssurl
  • rsstitle — display title? 0=No, 1=Yes
  • rssdesc — show the description text associated with the whole feed? 0=No, 1=Yes
  • rssimage — show the image associated with the whole feed? 0=No, 1=Yes
  • rssitems — number of items to display
  • rssitemdesc —show item description? 0=No, 1=Yes
  • word_count

Latest News: mod_latestnews

  • count
  • ordering — "c_dsc"=recently added first, "m_dsc"=recently modified first
  • user_id — a filter for the authors. 0=Anyone, "by_me"=added or modified by me, "not_me"=not added or modified by me.
  • show_front — Show frontpage items? 0=hide, 1=show
  • secid — section id
  • catid — category id

Login: mod_login

  • pretext
  • posttext
  • login — the Itemid (menu item id) of the menu item to redirect to after successful login
  • logout — the Itemid (menu item id) of the menu item to redirect to after logout
  • greeting — display the greeting text? 0=No, 1=Yes
  • name — style of greeting: 0=Username, 1=Name
  • usesecure — Encrypt login form? (requires SSL) 0=No, 1=Yes

Menu: mod_mainmenu

  • menutype — the “type” of the menu to be displayed. This is frequently "mainmenu" but may be "othermenu", "usermenu", or any other menu that you have set up.
  • menu_style — "list", "vert_indent", "horiz_flat" or "list_flat"
  • startLevel
  • endLevel
  • showAllChildren — Always show submenu items? 0=No, 1=Yes
  • window_position — Javascript values to position a popup window, e.g. "top=50,left=50,width=300,height=200"
  • show_whitespace — 0=No, 1=Yes
  • tag_id — Menu Tag ID. An ID attribute to assign to the root ul tag of the menu
  • class_sfx — a suffix to be applied to the CSS class of the menu items
  • moduleclass_sfx — a suffix to be applied to the CSS class of the module. This allows for individual module styling.
  • maxdepth — Maximum menu depth
  • menu_images — show menu icons? 0=No, 1=Yes
  • menu_images_align — Menu icon alignment 0=Left, 1=Right
  • menu_images_link — Menu icon link 0=No, 1=Yes
  • expand_menu — 0=No, 1=Yes
  • activate_parent — 0=No, 1=Yes
  • full_active_id — Full Active highlighting? 0=No, 1=Yes
  • indent_image — Choose which indent system to utilise: "0"=template, "1"=Joomla default images, "2"=use params below, "3"=none
  • indent_image1
  • indent_image2
  • indent_image3
  • indent_image4
  • indent_image5
  • indent_image6 — images for the first to sixth sublevel. The images must be in the folder /images/M_images, and these parameters must store the path and image name.
  • spacer — (text) spacer for horizontal menu
  • end_spacer — (text) end spacer for horizontal menu

Most Read Content: mod_mostread

  • show_front — Show frontpage items? 0=Hide, 1=Show
  • count — number of items to display
  • catid — category id
  • secid — section id

Newsflash: mod_newsflash

  • catid — category id
  • layout — "default"=randomly choose one at a time, "horiz"=horizontal, "vert"=vertical
  • image — show images? 0=No, 1=Yes
  • link_titles — make the item titles linkable? ""=Use Global, 0=No, 1=Yes
  • readmore — show/hide the Read More button? 0=Hide, 1=Show
  • item_title — show article title? 0=No, 1=Yes
  • items — number of items to display

Poll: mod_poll

  • id — the id number of the poll to display

Random Image: mod_random_image

  • type — Type of image PNG/GIF/JPG etc. (default is JPG)
  • folder — folder on the server with the images to be displayed.
  • link
  • width
  • height

Related Items: mod_related_items

  • showDate — show/hide date? 0=Hide, 1=Show

Search: mod_search

  • width — box width (number of characters)
  • text — text to display in empty search box
  • button — display a “Search” button? 0=No, 1=Yes
  • button_pos — "right" / "left" / "top" / "bottom"
  • imagebutton — display the search button as an image? ""=No, 1=Yes
  • button_text

Sections: mod_sections

  • count — number of items to display
  • show_noauth — show unauthorised links? 0=No, 1=Yes

Statistics: mod_stats

  • serverinfo — display server info?
  • siteinfo — display site info?
  • counter — display hit counter?
  • increase — the number of hits to increase the counter by

Syndicate: mod_syndicate

  • text — text to be displayed along with the RSS entries
  • format — "rss"=RSS 2.0, "atom"=Atom 1.0

Who’s Online: mod_whosonline

  • showmode — 0=number of guests/members, 1=member names, 2=both

Wrapper: mod_wrapper

  • url
  • scrolling — show horizontal and vertical scroll bars? "no" / "yes" / "auto"
  • width — e.g. "200" (pixels implied) or "100%" (percentage explicit)
  • height
  • height_auto — 0=No, 1=Yes
  • add — Auto Adding of "http://" to the front of the url field. 0=turn it off, 1=allow auto.
  • target — name of the iframe when used as a target
Last Updated on Tuesday, 13 October 2009 13:47