0

我有一段代码可以在我的登台服务器上正常工作,但它在我的本地主机上不能正常工作。我的模块中有这个文件john.module

drupal_add_css($filename . ".css");

在我的登台服务器上,$filename具有/sites/all/modules/john/style.css. 当我查看页面的源代码时,我看到既有@import样式表的声明,也有作为 json 数据提到的jQuery.extend(Drupal.settings).

在我的本地主机上,我小心地重新创建了暂存的文件目录结构。$filename具有相同的值。但是,当我查看页面的源代码时,我看不到样式表的 @import 语句。但是,它在 .json 数据中提到jQuery.extend(Drupal.settings)。如果注释掉drupal_add_css($filename.".css")上面的命令,那么它也会删除 json 数据中对样式表的提及。

我已清除缓存以确保它不是缓存问题。

所以我的问题是,为什么样式表显示在登台上而不是在我的本地主机上?

补充说明

我进行了一个实验并在这里列出了结果:

// when i use this line the css file is NOT included and I do NOT see an @import statement in the html document
drupal_add_css('/sites/all/modules/john/style.css')

// when i use this line the css file is successfully imported
drupal_add_css('sites/all/modules/john/style.css')

// when i use this line the css file is NOT included and I do NOT see an @import statement in the html document
drupal_add_css('http://johnwebsite.com/sites/all/modules/john/style.css');

// when i use this line the css file is NOT included but I do see an @import statement in the html document
drupal_add_css('/var/www/sites/all/modules/john/style.css');

那么为什么第一条规则适用于我的登台服务器而不适用于我的本地主机?

4

0 回答 0