使用className并注入css。即从我的分量小助手(见 “基督教儿童基金” 类)
函数定义:
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");
感谢队友!! :)设法解决问题后两天试图找出它....你的答案确实给了更多的见解:) – drew