Drupal 7:将文件名从template.php随机传递到css文件

Drupal 7:将文件名从template.php随机传递到css文件,php,css,variables,header,drupal-7,Php,Css,Variables,Header,Drupal 7,我的风景:我有一个安装了欧米茄主题的Drupal7 我的问题:我必须为css的特定区域(部分标题)设置一个随机背景。 由于响应设计,我有4个分开的css文件,文件名相同,但唯一的区别是“移动”\u窄”\u普通”\u宽后缀。 我在css文件中用一些简单的行设置了背景: #section-header { background: url(../images/sf_header_wide.jpg) no-repeat top center; height: 390px; margin: 0

我的风景:我有一个安装了欧米茄主题的Drupal7

我的问题:我必须为css的特定区域(部分标题)设置一个随机背景。 由于响应设计,我有4个分开的css文件,文件名相同,但唯一的区别是“移动”\u窄”\u普通”\u宽后缀。 我在css文件中用一些简单的行设置了背景:

#section-header {
  background: url(../images/sf_header_wide.jpg) no-repeat top center;
  height: 390px;
  margin: 0;
  padding: 0;  
}
我需要为背景添加多个图像,我想知道是否有可能从外部源(例如我的模板php文件)导入文件名,并在不向template.php文件添加背景行的情况下获得类似的内容,因为我已经为响应设计分离了css文件

#section-header {
      background: url("../images/<?php echo $fileimage; ?>_wide") no-repeat;
      height: 390px;
      margin: 0;
      padding: 0;  
    }
#节头{
背景:url(“../images/_-wide”)不重复;
高度:390px;
保证金:0;
填充:0;
}

有可能获得我需要的吗?

我不建议这样做,因为web浏览器将缓存您的CSS文件,因此如果您希望它每次都更改,它将不会更改。除此之外,这不是正常的做法

不过,你可以做一些事情来代替。一个是在页面标题本身中,只需像这样生成样式表

<head>
<link rel="stylesheet" type="text/css" href="primaryStyleSheet.css" media="screen" />
[...]All other head stuff, imports, responsive style sheet stuff here
<style>
/* Define this style AFTER the other CSS files are imported to be sure it loads */
#section-header {
  background: url("../images/<?php echo $fileimage; ?>_wide") no-repeat;
  height: 390px;
  margin: 0;
  padding: 0;  
}
</style>
</head>

[…]所有其他头部材料、导入、响应式样式表材料
/*在导入其他CSS文件后定义此样式,以确保加载*/
#节头{
背景:url(“../images/_-wide”)不重复;
高度:390px;
保证金:0;
填充:0;
}
此外,您还可以添加
!重要信息
到每个CSS定义(即高度:390px!重要信息;)