1

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) {
            unset($css['all']['module'][$value]);
        }

        $vars['styles'] = drupal_get_css($css);
    }
  • What version of Drupal? – Dylan Tack Sep 28 '11 at 21:11
  • v6 (minimum 15 char) – Allan Thomas Sep 28 '11 at 21:19
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. – Allan Thomas Sep 28 '11 at 21:41
  • Although, the preprocess seems to remove the IE-only files completely. – Allan Thomas Sep 28 '11 at 21:43
0

For Drupal 7, use the following code.

function ko_css_alter(&$css) {
  if (isset($css['sites/all/modules/contrib/module/file.css'])) { 
    unset($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 Apr 30 '12 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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