I need to remove all of the default css stylesheets drupal attaches to my theme. It's a pretty simple theme & site, and I don't want to bloat it with 1400+ lines of css that won't be used. One of the things that gets me with drupal theming is I spend half my time individually resetting drupal's default css instead of developing my own.
I noticed a topic around which involved a patch, that added the ability to remove default drupal stylesheets via the themes .info file - this was great until I realised that the css files were also removed in the admin theme (for which I am using Garland), making things pretty messy. I'd like to be able to individually remove the attached stylesheet elements for css files I don't want from the html (like system.css and default.css), to ease up the code and put a tiny little less strain on the server by opening up less connections - so removing instead of overriding is preffered.
So I'd like to do it through template.php - there are a few 5.x solutions which don't seem to work on 6.x
Anyone know of a decent way to remove the default css?
Comments
Maybe this helps
I was trying to get the same thing done and for me this works, but I'm not sure if it is the correct way as I'm still new to Drupal:
in "template.php" I added the following function:
I think after adding the function you need to go to /admin/build/themes so that Drupal recognises the function.
It is work!
Thanks!
an easy approach
You can remove
print $styles
from page.tpl.php. You'll also have to add link or import tags to include the theme style (style.css) and any other styles you want attached. It's really easy to just copy from the source code before you remove the "print $styles".I would be careful about removing styles, because you may end up breaking modules which use ajax/javascript and css.
-steve.
------------------------------------------------
http://www.designbrigade.com
Simple to remove
Howdy,
With drupal 6.x, you can use the theme.info file to overwrite the default system css files. For example, to over write the system menu default styling simply add:
stylesheets[all][] = system-menus.css
here is further explaination........
http://www.lullabot.com/blog/fixing-menu-css-themers-6
this is the best way
This is the simplest way to do it ^
DT
does not work!!! something is
does not work!!! something is dynamicvally loading system.css straight from core :(
This does work (I've just
This does work (I've just used it). http://drupal.org/node/263967
Hydrant Ltd
www.hydrant.co.uk
An alternative flexible approach
I found another solution to control the default styles -
not to use the general default stylesheet files, but instead of it
to copy, change and redirect the default stylesheet files for my concrete new theme.
It can be done as follows:
1) copy defaults.css from modules/system to the folder of your theme
2) make the necessary changes in the new defaults.css in your theme folder
3) redirect the css file path in your new theme page.tpl.php file -
this means, that change the defaults.css file path in the variable $styles with PHP preg_replace function
For example if the new theme (including the new copied defaults.css) files are in the folder sites/all/themes/drupal-test-theme,
then replace in your page.tpl.php file the code
print $styles
with the new code
Unbelievable
I can't believe this ignorance from Drupal developers. Obviously they are not web designers.
Sadness
The more I learn Drupal the more disappointed I become. So much cycles are being wasted in this bloated system. What - can't turn off CSS one by one?
Solutions:
1. Kill $styles ? The sub process(es) are still firing off from the core. Wasteful and bloated. nd I loose the "what should be cool" functionality.
2. Preg match / RegX - anyone know what the CPU cost is on that? (apparently not, it is taxing and should not be used for what is NORMALLY a simple task)
3. Overload (term used cautiously) - well we know PHP is a junky language (HTML + ECMA at best). Overload is not possible in PHP, and Drupal actually creates a work around for that (good job on implementing a solid pattern). But you now have the bloated wasteful Java type scenario. This is also cycle wasteful.
I am looking for a solution, non of these are really doing it for me. My CSS is SO TIGHT Drupal can't handle it with out me gutting the hell out of the template system. I already use my own header class because the header control in Drupal can't do what I need to do everyday.
I agree with Ishus.
...Still looking for a solution to a SIMPLE problem...
edit - solution:
// conditional for admin styles
if(!user_access('administer')){
$styles=null;
}
This will wipe the styles unless admin.
Overriding the core and module stylesheets
http://drupal.org/node/155400 -> Documentation page for "Overriding the core and module stylesheets"
Adam A. Gregory
_____________________________
Drupal Developer and Consultant
https://goo.gl/QSJjb2
Acquia Certified Developer-Back end Specialist
Okay, no I know.... Use
Okay, now I know.... Use Omega!
Drupal 7: Remove some default CSS styles
In Drupal 7 add this function to your template.php file in order to remove certain default CSS files from HTML:
$styles = preg_replace('//i',
$styles = preg_replace('/
/i', '', $styles);