How to clean stylsheets from Joomla head by using document->_styleSheets = - joomla

Joomla 2.5
as advised we are to use
$document = &JFactory::getDocument()
document->_styleSheets= array();
and place it in template before/after the head load to clear any css stylesheets from head ,
this works only for template css files , k2 css files but nothing else . if you have modules that use stylesheets , even if they used $document->addStyleSheet(path); properly the clear will not work for them
I also tested setHeadData() and all possible code that can be "found" ( joomla is bad in docs) and there is no simple way to rebuild the head plus none of them will hold a stylesheets from a module or plugin or any other component but k2.
Does anyone know a proper way to clean the head from all styles or js calls and place your own in there ?
thank you!

By this way you can only clean styles from components but not from modules or plugins. There is no way at the moment to handle this for all types. The only way is to use "ReReplacer" component to get rid of unwanted scripts or stylesheets.

You can clean the styles in the Template code like you sayed above.

This can be done using a system plugin.
A few of the available optimisation plugins allow you to remove unwanted scripts and stylesheets from the output.
http://jproven.com/extensions/jbetolo
http://sourceforge.net/projects/jch-optimize/

For anybody searching for this, heres a code that works with Joomla 2.5:
$doc= JFactory::getDocument();
unset($doc->_styleSheets['http://'.$_SERVER[HTTP_HOST].$this->baseurl.'/media/path/to/file.css']);

Related

Shopware 6 theme development - exclude specific Storefront styling or SCSS file

I have a CSS selector that gets a lot of styles from the built-in Storefront theme. I don't want to use any of those styles. Do I have to override/reset each single CSS property in my theme, or is there a way to exclude one specific Storefront SCSS file from compilation? Or even better, exclude that specific CSS selector?
I don't know a built in way to do this.
You might want to try to decorate the following method in a plugin and clear out the existing styles in the array
https://github.com/shopware/storefront/blob/fc16b8db664d077807073397b04ee3c56b7e3735/Theme/ThemeFileResolver.php#L27

Joomla cannot unset mod_languages/css/template.css

Joomla 3.x
The following code is not working
unset($doc->_styleSheets[JURI::root(true).'/media/mod_languages/css/template.css']);
thank you
The code is correct and I tested it, it's working fine.
Possibly you are running it in a plugin event after the head is rendered, or you have cached the page and the code is not really running.
In either case, try to put it at the component level, clear cache, and it should work
Update
to identify the component: turn SEF off, and look at the URL it shows as option=com_componentname;
to identify the module, simply rename the modules folder, and update the site; if it works, it's a module.
For plugins, rename the plugins/system and plugins/content first, then drill down until you spot it.
Alternatively, but much slower, you can turn modules and plugins on and off from the backend, until you find the culprit.
A variation which I've used with success in the past:
unset($doc->_styleSheets[$this->baseurl.'/media/mod_languages/css/template.css']);
Update
Here's an alternate method using a module override which should work for you.
if it doesn't already exist, create a new directory titled html in your template's folder, ie: /templates/your-template/html/
inside this, create an new mod_languages folder, ie /templates/your-template/html/mod_languages/
copy the file from joomla-site-root/modules/mod_languages/tmp/default.php to the folder above, ie /templates/your-template/html/mod_languages/default.php
open this file with a text editor and around line 12 look for the line where JHtml is loading the mod_languages CSS, and comment it out.
// JHtml::_('stylesheet', 'mod_languages/template.css', array(), true);
That's it, hopefully, this will do the trick for you.
Overriding Joomla core output using this method is safe and you won't loose your work with future Joomla updates.
More info about Joomla overrides:
https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
Good luck!

joomla autogenerated css classes

i want to make a new joomla template, i dropped into that but i am confused now.
i want to know where is the joomla autogenerated css class list.
for example i insert a module in template and what is the css class for example for menu title or the css class for search input box or what is the default css class for readmore link in main.
i found a little in joomla doc but i want the whole list
I fail to understand how you are prepared to make a Joomla template which is far more complex than a plain CSS template, yet you are unable to find the necessary CSS files. You said you wanted to make a new template therefore shouldn't you know where you have put the CSS file?
You are in dire need of Firebug for starters. Have a look at all it's features. It will help you to find CSS files and the specific line you need to edit.
I assume you are editing someone elses template in which case this is the sort of location you will be looking for.
templates/you_template/css/file.css
It varies with different template so I suggest you download Firebug as I suggested above.

How can i make customized template for the front end by overriding the default one?

I am new to Pyrocms and reading the documentation I could not change fix my problem. I need my own template to be incorporated that is I want to change the default one provided. How can I do that. I really need a help.
Go into:
system/cms/themes/default/
This is the folder where you can find the default template of pyrocms. There you will see folders like "views, css, js, img" etc.
You can start by modifying views/layouts/default.html and views/partials/ folder.
Ofcourse if you need to change css and/or js you need to modify them too.
By the way this is the official pyrocms documentation for editing themes:
http://www.pyrocms.com/docs/manuals/designers

joomla module, where to put css?

I've just written joomla module. This is basic but working version of my moule.
I want to 'effectize' it, so i need to work with some css. Elements of my module has own classes so i can style it very easy. But where to put CSS?
I typically just create a css folder under my module's directory. You can then use this call to include your css from your module's php code:
JDocument::addStyleSheet
Yes but would still recommend to put CSS in a seperate folder as suggested by Will Mavis as it is the right professional approach.
The assets for your Joomla extension should be put in the /media folder.
Eg:
For a module called mod_supermodule, put the files in:
/media/mod_supermodule/css
/media/mod_supermodule/images
/media/mod_supermodule/js

Resources