I am trying to load a css file to the homepage only in drupal 7 and have gotten help in do that. Now I need to omit another css file only on the hompage. I thought I could add and else statement but that produced an error. here is the code from the template.php file.
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');
}
}
this is what I tried:
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');
}
can someone tell me why this doesn’t work?
You’ve just missed the the closure for the else statement (missing a curly bracket). Change your code to the following: