Following this guide I created a custom page--404.tpl.php
page for my custom 404 Not found page. We put this in template.php
:
function themename_preprocess_page(&$vars) {
// Adds a Custom 404 page
$header = drupal_get_http_header("status");
if($header == "404 Not Found") {
$vars['theme_hook_suggestions'][] = 'page__404';
}
}
Now I need to load CSS only when that page is loaded. This here only shows how to load it in either node or front page, but not custom 404 page.
This does not work:
$header = drupal_get_http_header("status");
if($header == "404 Not Found") {
$vars['theme_hook_suggestions'][] = 'page__404';
drupal_add_css(drupal_get_path('theme', 'dev') . "css/404/bootstrap.css");
drupal_add_css(drupal_get_path('theme', 'dev') . "css/404/custom-style.css");
}
}
drupal_add_css(drupal_get_path('theme', 'MYTHEME') . "/css/foo.css");
in your if condition, if that works. Because you're already checking header. – Yogesh Sep 28 '16 at 9:07