使用这些片段来管理您的问题:
1) 通过检查活动菜单项来加载 CSS
$menu = &JSite::getMenu();
$menuItem = $menu->getActive();
$Itemid = $menuItem->id;
if($Itemid!=1)
{
$doc->addStyleSheet($pluginAssetsUrl . '/css/aecuserpage.css');
}
2) 在组件上加载 CSS
if (JRequest::getCmd( 'option' ) == 'com_k2'){
$doc->addStyleSheet($pluginAssetsUrl . '/css/aecuserpage.css');
}
3) 仅在主页加载 CSS
<?php if(JRequest::getInt('Itemid') == $menu->getDefault()) {
$doc->addStyleSheet($pluginAssetsUrl . '/css/aecuserpage.css');
}?>
4) 在活动菜单 id 上加载 CSS
<?php
$menuID = JSite::getMenu()->getActive()->id ;
if ($menuID == '6')
{
$doc->addStyleSheet($pluginAssetsUrl . '/css/aecuserpage.css');
}
?>
5)在活动语言上加载 CSS:
$lang =& JFactory::getLanguage();
switch ($lang) {
case 'en-gb':
$doc->addStyleSheet($pluginAssetsUrl . '/css/aecuserpage.css');
break;
}
6)在用户身上加载CSS
$user =& JFactory::getUser();
if($user->get('id')==0){
//user is logged in
$doc->addStyleSheet($pluginAssetsUrl . '/css/aecuserpage.css');
}
7) 在 URL 上加载 CSS
$u =& JFactory::getURI();
if($u=="http://www.example.com/joomla/index.php?task=view&id=12&Itemid=29")
{
$doc->addStyleSheet($pluginAssetsUrl . '/css/aecuserpage.css');
}