Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何强制Drupal在CSS上不使用导入?_Drupal_Drupal 7_Drupal Theming - Fatal编程技术网

如何强制Drupal在CSS上不使用导入?

如何强制Drupal在CSS上不使用导入?,drupal,drupal-7,drupal-theming,Drupal,Drupal 7,Drupal Theming,我想使用一个脚本来重新加载CSS,但该脚本使用标记,Drupal使用导入来包含CSS(在开发站点上不使用聚合时) 我尝试使用hook\u alter\u css,但显然(使用dpm函数)这不是导入的来源。 那么,我怎样才能覆盖这个行为呢? 谢谢 关闭聚合时会发生这种情况。如果使用自定义主题,则需要解决此问题 在template.php文件中添加css文件时:- drupal_add_css(path_to_subtheme() .'/layout.css', 'theme', 'all', $p

我想使用一个脚本来重新加载CSS,但该脚本使用标记,Drupal使用导入来包含CSS(在开发站点上不使用聚合时)

我尝试使用hook\u alter\u css,但显然(使用dpm函数)这不是导入的来源。 那么,我怎样才能覆盖这个行为呢?
谢谢

关闭聚合时会发生这种情况。如果使用自定义主题,则需要解决此问题 在template.php文件中添加css文件时:-

drupal_add_css(path_to_subtheme() .'/layout.css', 'theme', 'all', $preprocesstheme);
$preprocesstheme set it to  false (true aggration is turned on).
使用此方法包含所有css文件。

您也可以使用模块来实现此目的

或者,在您自己的自定义模块中,使用
hook\u css\u alter
,如下所述:


我马上就去试试。谢谢
/**
 *  Implements hook_css_alter().
 */ 
function mymodule_css_alter(&$css) {
  $preprocess_css = variable_get('preprocess_css', TRUE);
  if (!$preprocess_css) {
    // For each item, don't allow preprocessing to disable @import.
    foreach ($css as &$item) {
      if (file_exists($item['data'])) {
        $item['preprocess'] = FALSE;
      }
    }
  }
}