Last reviewed: 18 Nov 2005, Joomla 1.0.3


Counts the number of module(s) in the specified position.

This function determines the number of modules in a given position. It is used primarily in the front end by the templates for the purpose of layout and styling.

Returns an integer equal to the number of modules in the specified position. The position parameters defaults to 'left'.

This function will return 1 if the GET variable tp is true. The tp variable is used by the Site Preview function in the adminstration backend. If the site is being previewed with positions, then tp is set to 1. Otherwise, tp is set to 0.


int mosCountModules ( [ string $position ] )

is a string containing the position for which to count the modules (e.g. 'top', 'left', 'bottom', 'right', 'user1'). This parameter is optional and if omitted will default to 'left'.

Defined in

(includes/frontend.php prior to Joomla 1.1)


Example: Counting the modules in the left position.

function displayLeftModulesCount() {
    $leftModuleCount = mosCountModules( 'left' );
    echo "There are $leftModuleCount modules in the left position.";

might produce:

There are 2 modules in the left position.

Please report any errors on this page to the Developer Documentation Forum.

Last Updated ( Tuesday, 03 January 2006 )