Joomla - 从组件中删除不需要的css


Joomla - remove unwanted css from within component

我正在设计一个自定义组件,其中我利用 tmpl=component 功能仅呈现组件而不是显示默认模板。

如何在组件本身中删除正在产生样式冲突的站点头部中不需要的 css 文件?

我知道有两种方法:

1)获取文档对象的实例并删除CSS文件:

<?php 
         //get the array containing all the script declarations
         $document = JFactory::getDocument(); 
         $headData = $document->getHeadData();
         $styles = $headData['styles'];
         //remove your script, i.e. mootools
         unset($styles['/media/system/css/acc.css']);
         $headData['styles'] = $styles;
         $document->setHeadData($headData);
?>

2) 直接从模板索引中删除 CSS 文件.php:

<?php unset($this->_styles['/media/system/css/acc.css']); ?>

要取消设置不需要的js或css并加载您想要的任何内容,您可以使用出色的插件 https://extensions.joomla.org/extension/eorisis-jquery/