Counting modules in a given module position/ru: Difference between revisions

From Joomla! Documentation

Created page with "Подсчет модулей, [назначенных] определенной позиции"
 
Created page with "Метод <tt>countModules</ tt> может использоваться в шаблоне для определения количества модулей, включенн..."
Line 1: Line 1:
<noinclude><languages /></noinclude>
<noinclude><languages /></noinclude>
The <tt>countModules</tt> 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”.
Метод <tt>countModules</ tt> может использоваться в шаблоне для определения количества модулей, включенных в данной позиции модуля. Это обычно используется для включения HTML вокруг модулей в определенную позицию, только если для этой позиции включен хотя бы один модуль. Это предотвращает определение пустых областей в выводе шаблона и представляет собой метод, иногда называемый «коллапсирующими столбцами».


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

Revision as of 15:09, 17 September 2018

Метод countModules</ tt> может использоваться в шаблоне для определения количества модулей, включенных в данной позиции модуля. Это обычно используется для включения HTML вокруг модулей в определенную позицию, только если для этой позиции включен хотя бы один модуль. Это предотвращает определение пустых областей в выводе шаблона и представляет собой метод, иногда называемый «коллапсирующими столбцами».

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' )) : ?>
  <div class="user1">
    <jdoc:include type="modules" name="user1" style="rounded" />
  </div>
<?php endif; ?>