I would like to prevent several contributed modules from using their own css files. Constantly having to reset their css and then apply your own is a waste of bandwidth IMO.

I tried this out with nice_menus and it didn't seem to do anything.

Placed in template.php

    function phptemplate_variables($hook, $vars) {
        $css = drupal_add_css();

        $rm[] = drupal_get_path('module','nice_menus').'/nice_menus.css';
        $rm[] = drupal_get_path('module','nice_menus').'/nice_menus_default.css';

        foreach ($rm as $key => $value) {

        $vars['styles'] = drupal_get_css($css);
  • What version of Drupal?
    – Dylan Tack
    Commented Sep 28, 2011 at 21:11
  • v6 (minimum 15 char) Commented Sep 28, 2011 at 21:19

2 Answers 2


I think the function should be named MYTHEME_preprocess_page. Though a more common method is to add

stylesheets[all][] = nice_menus.css

to your theme's .info file. nice_menus.css will be replaced by the one provided by your theme, or suppressed entirely if your theme doesn't contain this file.

  • Great thanks for your help. Both solutions worked. Commented Sep 28, 2011 at 21:41
  • Although, the preprocess seems to remove the IE-only files completely. Commented Sep 28, 2011 at 21:43

For Drupal 7, use the following code.

function ko_css_alter(&$css) {
  if (isset($css['sites/all/modules/contrib/module/file.css'])) { 
  • In D6 if you have the advagg module installed you can use hook_advagg_css_pre_alter to accomplish the same thing.
    – mikeytown2
    Commented Apr 30, 2012 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.