gpt4 book ai didi

drupal - CSS文件加载主页只省略其他drupal 7

转载 作者:行者123 更新时间:2023-12-04 06:03:59 30 4
gpt4 key购买 nike

我正在尝试仅在 drupal 7 中将 css 文件加载到主页,并已获得帮助。现在我只需要在主页上省略另一个 css 文件。我以为我可以添加和 else 语句,但这产生了错误。这是 template.php 文件中的代码。

function fource_preprocess_html(&$vars) {
if($vars['is_front']) {
drupal_add_js(drupal_get_path('theme','fource').'/js/image_scale.js');
drupal_add_css(drupal_get_path('theme','fource').'/css/index_style.css');
}
}

这是我试过的:
function fource_preprocess_html(&$vars) {
if($vars['is_front']) {
drupal_add_js(drupal_get_path('theme','fource').'/js/image_scale.js');
drupal_add_css(drupal_get_path('theme','fource').'/css/index_style.css');
}else{
drupal_add_css(drupal_get_path('theme','fource').'/css/main.css');
}

有人能告诉我为什么这不起作用吗?

最佳答案

您刚刚错过了 else 语句的闭包(缺少大括号)。将您的代码更改为以下内容:

function fource_preprocess_html(&$vars) {
if ($vars['is_front']) {
drupal_add_js(drupal_get_path('theme','fource').'/js/image_scale.js');
drupal_add_css(drupal_get_path('theme','fource').'/css/index_style.css');
}
else {
drupal_add_css(drupal_get_path('theme','fource').'/css/main.css');
} // <-- this is the bit you're missing
}

关于drupal - CSS文件加载主页只省略其他drupal 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8583786/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com