Counting modules in a given module position

From Joomla! Documentation
(Difference between revisions)
Jump to: navigation, search
m
m (Counting Modules in a given Module position)
Line 1: Line 1:
=== Counting Modules in a given Module position ===
+
<includeonly>=== Counting Modules in a given Module position ===</includeonly>
  
 
The countModules function can be used within a template to determine the number of Modules enabled in a given Module position.  This is commonly used to include Modules in a certain position only if at least one Module is enabled for that position.  This prevents empty regions from being defined in the template output.
 
The countModules function can be used within a template to determine the number of Modules enabled in a given Module position.  This is commonly used to include Modules in a certain position only if at least one Module is enabled for that position.  This prevents empty regions from being defined in the template output.

Revision as of 14:07, 22 May 2008


The countModules function can be used within a template to determine the number of Modules enabled in a given Module position. This is commonly used to include Modules in a certain position only if at least one Module is enabled for that position. This prevents empty regions from being defined in the template output.

For example, the following code includes Modules in the 'user1' position only if at least one Module is enabled for that position.

<?php if ($this->countModules( 'user1' )) : ?>
 
        <jdoc:include type="modules" name="user1" style="rounded" />
 
<?php endif; ?>
Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox