Mitchell Oak
Mitchell Oak

Reputation: 13

Joomla - remove unwanted css from within component

I'm designing a custom component where I am utilising the tmpl=component ability to render the component only rather than displaying the default template.

How can I, within the component itself remove the unwanted css files from the sites head which are creating a styling conflict?

Upvotes: 0

Views: 3240

Answers (2)

Erick Boileau
Erick Boileau

Reputation: 494

to unset unwanted js or css and to load whatever you want you can use the excellent plugin https://extensions.joomla.org/extension/eorisis-jquery/

Upvotes: 0

Umair Ayub
Umair Ayub

Reputation: 21201

There are two ways that I am aware of:

1) get an instance of the document object and remove the CSS files :

<?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) remove CSS files directly from your template index.php:

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

Upvotes: 1

Related Questions