我正在让一个Drupal站点在我的本地主机上工作。目前,它似乎输出了一些内容(数据库正在工作),但没有任何样式。
当我查看源代码时,我看到的是:
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="all" />
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="all" />
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="all" />
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="screen" />
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="all" />
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="all" />
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="all" />
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="print" />
<link type="text/css" rel="stylesheet" href="http://localhost:88/sites/MAA/" media="all" />
<script type="text/javascript" src="http://localhost:88/sites/MAA/sites/all/modules/jquery_update/replace/jquery/1.8/jquery.min.js?v=1.8.3"></script>
也就是说,除了网站的路径部分外,模板的CSS没有被包括在内。现在,.info文件如下:
; Stylesheets. Anything within the "framework" folder will be placed before all others.
stylesheets[all][] = styles/framework/reset.css
stylesheets[all][] = styles/framework/text.css
stylesheets[all][] = styles/framework/960.css
stylesheets[all][] = styles/framework/debug.css
stylesheets[all][] = styles/css/css_hides.css
; Theme specific styles. Any sub-themes should override this.
stylesheets[all][] = styles/skin.css
stylesheets[all][] = styles/maa.css
stylesheets[all][] = styles/maa-legacy.css
stylesheets[all][] = styles/jq-ui-date-range-picker/ui.daterangepicker.css
stylesheets[all][] = styles/styles_nvl.css
stylesheets[all][] = styles/css_hides.css
stylesheets[print][] = styles/print.css
; Theme specific scripts.
scripts[] = "js/enlargeit.js"
scripts[] = "js/jquery-ui.js"
scripts[] = "js/custom.js"
regions[page_top] = Page top
regions[header] = Header
regions[search_box] = Search Box
regions[main_nav] = Main Navigation
regions[highlighted] = Highlight
regions[featured] = Featured
regions[help] = Help
regions[home_content] = Home Content
regions[home_content_bottom] = Home Content Bottom
regions[content] = Content
regions[sidebar_first] = Left sidebar
regions[sidebar_second] = Right sidebar
regions[footer_top] = Footer Top
regions[footer_top_left] = Footer Top Left
regions[footer_top_center_one] = Footer Top Center 1
regions[footer_top_center_two] = Footer Top Center 2
regions[footer_top_right] = Footer Top Right
regions[footer_left] = Footer Left
regions[footer_right] = Footer Right
regions[page_bottom] = Page bottom
有人能告诉我应该在哪里解决这个问题吗?在html.tpl.php文件中,有一行输出样式,但我找不到它的填充位置。
<?php print $styles; ?>
<?php print $scripts; ?>
解决Drupal问题的第一步:你试过清理缓存了吗?(这相当于Drupal的"你试过关闭它然后再打开它吗?")
如何清除缓存:如果您是以管理员身份登录网站的,请转到"配置">"开发">"性能"。您应该看到一个"清除所有缓存"按钮。
如果不起作用:你查过Drupal的文档了吗?https://www.drupal.org/node/171209
如果聚合和压缩CSS文件(配置>开发>性能中的设置),会发生什么?
我刚刚在将生产站点克隆到本地机器上时遇到了这个问题。生产和暂存环境都很好,所以我开始对我的机器进行故障排除。
当遇到这个具体问题时,前面的答案绝对是一个很好的起点。然而,真正的罪魁祸首似乎是Drupal在注册样式表时如何使用文件系统。
一般来说,html.tpl.php
文件将有一个$styles
变量。这是一个输出字符串,包含您在主题的.info
文件中注册的所有样式表。您可能有也可能没有预处理钩子来更改template.php
文件中的css文件。
在追踪所有这些并确认其正确后,运行系统状态报告将帮助您确定需要解决的领域。在这个特定的场景中,它是一个使用ctools
模块的Drupal7站点。登录后浏览/admin/reports/status
发现ctools无法在/sites/default/files/ctools/
中创建正确的目录。
结果是,如果Drupal不能创建这个目录,它会从我的样式表中删除URI。驱动每个样式表输出的数据来自.info
和任何添加css的预处理函数。
我希望这能帮助到其他遇到这个问题的人。