Last active
August 4, 2016 13:49
-
-
Save gwarnants/736d3c13a2736bc75e10ba239056a057 to your computer and use it in GitHub Desktop.
Add HTTP status header as a body class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_preprocess_html(). | |
*/ | |
function <theme>_preprocess_html(&$variables) | |
{ | |
$header = drupal_get_http_header('status'); | |
if ($header && preg_match('`^[0-9]+`', $header, $matches)) { | |
switch ($matches[0]) { | |
case 403: | |
case 404: | |
$variables['classes_array'][] = 'http-status-'.$matches[0]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment