Comptage des modules dans une position de module donnée

From Joomla! Documentation

This page is a translated version of the page Counting modules in a given module position and the translation is 100% complete.

Other languages:
български • ‎Deutsch • ‎English • ‎español • ‎français • ‎Nederlands • ‎русский

The countModules method can be used within a template to determine the number of modules enabled in a given module position. This is commonly used to include HTML around 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 and is a technique sometimes referred to as “collapsing columns”.

Par exemple, le code suivant prend en compte les modules de la position 'user1' uniquement si au moins un module est activé pour cette position.

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