className を使用して css を挿入します。つまり、私のコンポーネントである Little Helper (「ccfs」クラスを参照)
関数定義:
custom($task = '', $icon = '', $iconOver = '',...
私のコード:
JToolBarHelper::custom( 'trash_n_cache.cleanfscache','ccfs' ,'ccfs',...
Joomla 2.5 でこのマークアップをレンダリングします。
<a class="toolbar" onclick="Joomla.submitbutton('trash_n_cache.cleanfscache')" href="#">
<span class="icon-32-ccfs"></span>
Clean cache
</a>
Joomla 3.x のこのマークアップ:
<button class="btn btn-small" onclick="Joomla.submitbutton('trash_n_cache.cleanfscache')" href="#">
<i class="icon-ccfs "></i>
Clean cache
</button>
そして、次のようにスタイルを設定します: (J2.5 のアイコンは 32*32、Joomla 3.x では 16*16 であることに注意してください)
.icon-16-ccfs, i.icon-ccfs {
background-image:
url(../images/cachefs16.png)
}
.icon-32-ccfs {
background-image:
url(../images/cachefs32.png)
}
次のいずれかを注入できます。
$document = JFactory::getDocument();
$document->addStyleDeclaration($cssRules)
または、外部 css のリソースとしてリンクします。
$document = JFactory::getDocument();
$document->addStyleSheet("components/com_littlehelper/assets/css/littlehelper.css");