Drupal主题不会读取CSS文件

时间:2023-02-06 12:16:07

I'm currently working on a drupal theme but keep having problems with getting the theme to read the damn css file. I started off theming with the Framework theme, I tried organising the files on there for example creating a subdirectory to store the CSS file, change the setting in the .info file so it knows it's in the css folder, but it won't read the damn file.

我目前正在研究一个drupal主题,但一直有问题让主题阅读该死的css文件。我开始使用Framework主题,我尝试在那里组织文件,例如创建一个子目录来存储CSS文件,更改.info文件中的设置,以便它知道它在css文件夹中,但它不会读取该死的档案。

Fast forward a few days and I've got 60% of my theme styled and layout-ed, so decided to port everything into a new theme folder rather than the Framework theme folder. Organised the folders and files, but again it won't read the CSS file whether I put it in a subdirectory or in the same directory as the .info file. It somehow worked once, but then went and hasn't worked again.

快进几天,我有60%的主题风格和布局,所以决定将所有东西都移植到一个新的主题文件夹而不是框架主题文件夹。组织文件夹和文件,但无论是将它放在子目录中还是与.info文件放在同一目录中,它都不会读取CSS文件。它以某种方式工作了一次,但后来又没有再工作了。

I've tried clearing the cache etc, but to no avail.

我已经尝试清除缓存等,但无济于事。

I'm working on a local wamp server. Drupal is latest version 7.

我正在研究一个本地的wamp服务器。 Drupal是最新版本7。

Any ideas how to fix this problem?

任何想法如何解决这个问题?

Thank you

2 个解决方案

#1


0  

Wich version of Drupal you are using? In Drupal 6 this works fine:

你正在使用的是什么版本的Drupal?在Drupal 6中这很好用:

/* mytheme.info */
stylesheets[all][]   = assets/css/master.css
stylesheets[all][]   = assets/css/typo.css

This files are in my Theme folder

此文件位于我的主题文件夹中

Folder: MYTHEME
   File: mytheme.info
   Folder: assets
       Folder: css
           File: master.css
           File: typo.css

#2


0  

I know this is a bit late but maybe it will help someone else.

我知道这有点晚了但也许会帮助别人。

I'm using Drupal 7 and I attempted to add a javascript and stylesheet file in a custom module in the .info file.

我正在使用Drupal 7,我试图在.info文件的自定义模块中添加一个javascript和样式表文件。

module.always.js and module.always.css

module.always.js和module.always.css

It would load the first but not the second. I even put the stylesheet above the script in the info file and it would still just load the first file. Thought it was the directory and tried adding quotes around the file paths but that did nothing. Also thought it was the extra . in the file name but that didn't matter either.

它会加载第一个而不是第二个。我甚至将样式表放在信息文件中的脚本上方,它仍然只是加载第一个文件。以为这是目录,并尝试在文件路径周围添加引号,但没有做任何事情。也认为这是额外的。在文件名中,但无关紧要。

The only way I could get both files to load was to remove them from the .info file and add a drupal_add_js and drupal_add_css for these files in the module_init() function.

我可以将两个文件加载的唯一方法是从.info文件中删除它们,并在module_init()函数中为这些文件添加drupal_add_js和drupal_add_css。

No clue why that is the case but at least there is a work around.

不知道为什么会这样,但至少有一个解决方法。

#1


0  

Wich version of Drupal you are using? In Drupal 6 this works fine:

你正在使用的是什么版本的Drupal?在Drupal 6中这很好用:

/* mytheme.info */
stylesheets[all][]   = assets/css/master.css
stylesheets[all][]   = assets/css/typo.css

This files are in my Theme folder

此文件位于我的主题文件夹中

Folder: MYTHEME
   File: mytheme.info
   Folder: assets
       Folder: css
           File: master.css
           File: typo.css

#2


0  

I know this is a bit late but maybe it will help someone else.

我知道这有点晚了但也许会帮助别人。

I'm using Drupal 7 and I attempted to add a javascript and stylesheet file in a custom module in the .info file.

我正在使用Drupal 7,我试图在.info文件的自定义模块中添加一个javascript和样式表文件。

module.always.js and module.always.css

module.always.js和module.always.css

It would load the first but not the second. I even put the stylesheet above the script in the info file and it would still just load the first file. Thought it was the directory and tried adding quotes around the file paths but that did nothing. Also thought it was the extra . in the file name but that didn't matter either.

它会加载第一个而不是第二个。我甚至将样式表放在信息文件中的脚本上方,它仍然只是加载第一个文件。以为这是目录,并尝试在文件路径周围添加引号,但没有做任何事情。也认为这是额外的。在文件名中,但无关紧要。

The only way I could get both files to load was to remove them from the .info file and add a drupal_add_js and drupal_add_css for these files in the module_init() function.

我可以将两个文件加载的唯一方法是从.info文件中删除它们,并在module_init()函数中为这些文件添加drupal_add_js和drupal_add_css。

No clue why that is the case but at least there is a work around.

不知道为什么会这样,但至少有一个解决方法。