Counting modules in a given module position/zh-tw: Difference between revisions
From Joomla! Documentation
Created page with "計算模組位置多少模組使用" |
Created page with "例如,以下的程式碼會計算 <code>user1</code> 模組位置" |
||
| Line 3: | Line 3: | ||
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”. | 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”. | ||
例如,以下的程式碼會計算 <code>user1</code> 模組位置 | |||
<source lang="php"> | <source lang="php"> | ||
Revision as of 06:08, 29 January 2021
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”.
例如,以下的程式碼會計算 user1 模組位置
<?php if ($this->countModules( 'user1' )) : ?>
<div class="user1">
<jdoc:include type="modules" name="user1" style="rounded" />
</div>
<?php endif; ?>