Remove Unwanted Stylesheets from Drupal 6


/ Published in: PHP
Save to your folder(s)

Put this in the template.php within your template directory.


Copy this code and paste it in your HTML
  1. /* simple example */
  2. function phptemplate_preprocess_page(&$vars)
  3. {
  4. drupal_add_css(THEMEPATH.'/css/sifr.css','theme');
  5. $css = drupal_add_css();
  6. //unset($css['all']['module']['modules/system/system.css']);
  7. //unset($css['all']['module']['modules/system/defaults.css']);
  8. //unset($css['all']['module']['modules/system/system-menus.css']);
  9. unset($css['all']['module']['modules/user/user.css']);
  10. unset($css['all']['module']['modules/taxonomy/taxonomy.css']);
  11. unset($css['all']['module']['sites/all/modules/cck/theme/content-module.css']);
  12. unset($css['all']['module']['sites/all/modules/logintoboggan/logintoboggan.css']);
  13. unset($css['all']['module']['sites/all/modules/ubercart/uc_product/uc_product.css']);
  14. unset($css['all']['module']['sites/all/modules/cck/modules/fieldgroup/fieldgroup.css']);
  15. unset($css['all']['module']['sites/all/modules/filefield/filefield.css']);
  16. unset($css['all']['module']['sites/all/modules/img_assist/img_assist.css']);
  17. unset($css['all']['module']['sites/all/modules/link/link.css']);
  18. $vars['styles'] = drupal_get_css($css);
  19. }
  20.  
  21. /* whitelist */
  22. function pbot_preprocess_page(&$v)
  23. {
  24. $css = drupal_add_css();
  25. foreach( $css['all']['module'] as $stylesheet => $val )
  26. {
  27. $matches = array();
  28. preg_match('@(devel|date|wysiwyg|tinymce|admin_menu|imce)@',$stylesheet,$matches);
  29. if( strpos($stylesheet,'sites/all/modules') !== false && empty($matches) )
  30. {
  31. unset($css['all']['module'][$stylesheet]);
  32. }
  33. }
  34.  
  35. $v['styles'] = drupal_get_css($css);
  36. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.