user376112
user376112

Reputation: 869

Drupal : How to remove default.css in the .module file?

Is it possible to remove the module/system/default.css file. I'd like to do this in the .module file and not in the template.php file.

My goal is to disable this style in my drupal website without manipulating a template/theme.

Is it possible?

Thanks in advance,

Bat

Upvotes: 1

Views: 535

Answers (1)

David Eads
David Eads

Reputation: 1512

This is possible. You can use template_preprocess_page in your custom module to whack Drupal's default CSS:

function mymodule_preprocess_page(&$vars) {
  // Get CSS array and remove selected stylesheets
  $css = drupal_add_css(); 
  unset($css['all']['module']['modules/system/defaults.css']);

  // Override Drupal styles
  $vars['styles'] = drupal_get_css($css);
}

Because of Drupal's architecture, you'll almost certainly need to set the module weight to something greater than your other installed modules to ensure that your preprocessor runs last and no other module will be adding CSS.

Upvotes: 5

Related Questions