PHP 从Drupal 6中删除不需要的样式表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 从Drupal 6中删除不需要的样式表相关的知识,希望对你有一定的参考价值。

/* simple example */
function phptemplate_preprocess_page(&$vars)
{
  drupal_add_css(THEMEPATH.'/css/sifr.css','theme');
  $css = drupal_add_css();
  //unset($css['all']['module']['modules/system/system.css']);
  //unset($css['all']['module']['modules/system/defaults.css']);
  //unset($css['all']['module']['modules/system/system-menus.css']);
  unset($css['all']['module']['modules/user/user.css']);
  unset($css['all']['module']['modules/taxonomy/taxonomy.css']);
  unset($css['all']['module']['sites/all/modules/cck/theme/content-module.css']);
  unset($css['all']['module']['sites/all/modules/logintoboggan/logintoboggan.css']);
  unset($css['all']['module']['sites/all/modules/ubercart/uc_product/uc_product.css']);
  unset($css['all']['module']['sites/all/modules/cck/modules/fieldgroup/fieldgroup.css']);
  unset($css['all']['module']['sites/all/modules/filefield/filefield.css']);
  unset($css['all']['module']['sites/all/modules/img_assist/img_assist.css']);
  unset($css['all']['module']['sites/all/modules/link/link.css']);
  $vars['styles'] = drupal_get_css($css);
}

/* whitelist */
function pbot_preprocess_page(&$v)
{
  $css = drupal_add_css();
  foreach( $css['all']['module'] as $stylesheet => $val )
  {
    $matches = array();
    preg_match('@(devel|date|wysiwyg|tinymce|admin_menu|imce)@',$stylesheet,$matches);
    if( strpos($stylesheet,'sites/all/modules') !== false && empty($matches) )
    {
      unset($css['all']['module'][$stylesheet]);
    }
  }

  $v['styles'] = drupal_get_css($css);
}

以上是关于PHP 从Drupal 6中删除不需要的样式表的主要内容,如果未能解决你的问题,请参考以下文章

PHP 从Drupal节点中删除样式标记

在Drupal中有选择地删除样式表以获取页面

PHP Drupal - 取消设置(不包括)所有核心样式表 - 主题变量覆盖。

PHP Drupal克服IE 31样式表限制

Drupal-取消设置(不包括)所有核心样式表-主题变量覆盖。

Drupal 6:在 tpl.php 中对多个值进行分组