Created
September 23, 2014 18:51
-
-
Save swirtSJW/e298ace654171d3120a1 to your computer and use it in GitHub Desktop.
Replace the existing hook_init with something like this... unless the existing init has other stuff in it. Then just move these items out.
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
/** | |
* Implements hook_boot(). | |
*/ | |
function local_framework_boot() { | |
// Set http header to force ie to edge mode to prevent compatibility-mode. | |
// This is the default behaviour. On all but prod set doj_theme_ie_to_edge=0. | |
if (!empty($_GET) && !empty($_GET['debug']) && ($_GET['debug'] == 'ie')) { | |
// There is a debug so do not force to use edge, do nothing. | |
} | |
else { | |
// There is no debugging going on, so force ie to use edge. | |
// Send X-UA-Compatible HTTP header to force IE to use the most recent | |
// rendering engine or use Chrome's frame rendering engine if available. | |
// It is not possible to use drupal_add_http_header() as Drupal 7 does not | |
// store HTTP headers in the page cache. | |
header('X-UA-Compatible: IE=edge'); | |
} | |
} | |
/** | |
* Implements hook_preprocess_page(). | |
*/ | |
function local_framework_preprocess_page(&$variables) { | |
// Set http header to force ie to edge mode to prevent compatibility-mode. | |
if (!empty($_GET) && !empty($_GET['debug']) && ($_GET['debug'] == 'ie')) { | |
// There is a debug so do not force to use edge, do nothing. | |
} | |
else { | |
// There is no debugging going on, set the meta tag for edge. | |
$element = array( | |
'#tag' => 'meta', | |
'#attributes' => array( | |
'http-equiv' => 'X-UA-Compatible', | |
'content' => 'IE=edge', | |
), | |
); | |
// This element has no effect on forcing edge, but is a visual indicator in | |
// the html head of what is happening. If it is present, so is the header. | |
drupal_add_html_head($element, 'x_ua_compatible'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment