Skip to content

Instantly share code, notes, and snippets.

@gwarnants
Last active August 4, 2016 13:49
Show Gist options
  • Save gwarnants/736d3c13a2736bc75e10ba239056a057 to your computer and use it in GitHub Desktop.
Save gwarnants/736d3c13a2736bc75e10ba239056a057 to your computer and use it in GitHub Desktop.
Add HTTP status header as a body class
<?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