Counting modules in a given module position/zh-tw: Difference between revisions
From Joomla! Documentation
Created page with "<tt>countModules</tt> method 可以在佈景主題中用來計算,有多少個啟用的模組用在這個位置。這可以用於模組相鄰的 HTML 程式碼,來知道..." |
|||
| Line 1: | Line 1: | ||
<noinclude><languages /></noinclude> | <noinclude><languages /></noinclude> | ||
<tt>countModules</tt> method 可以在佈景主題中用來計算,有多少個啟用的模組用在這個位置。這可以用於模組相鄰的 HTML 程式碼,來知道特定的模組位置至少有一個啟用中的模組。這會避免空白的範圍在佈景主題中被定義,此外這個技巧也常用於 “ 收摺欄”。 | |||
例如,以下的程式碼會計算 <code>user1</code> 模組位置 | 例如,以下的程式碼會計算 <code>user1</code> 模組位置 | ||
Latest revision as of 06:14, 29 January 2021
countModules method 可以在佈景主題中用來計算,有多少個啟用的模組用在這個位置。這可以用於模組相鄰的 HTML 程式碼,來知道特定的模組位置至少有一個啟用中的模組。這會避免空白的範圍在佈景主題中被定義,此外這個技巧也常用於 “ 收摺欄”。
例如,以下的程式碼會計算 user1 模組位置
<?php if ($this->countModules( 'user1' )) : ?>
<div class="user1">
<jdoc:include type="modules" name="user1" style="rounded" />
</div>
<?php endif; ?>