Revision: 34159
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 18, 2010 19:24 by resting
Initial Code
<?php
// Consolidate all styles import into 1 style tag. Solves IE 31 style tag limit
$styles_document = new DOMDocument();
$styles_document->loadHTML($vars['styles']);
$style_elements = $styles_document->getElementsByTagName('style');
$stylesheets = '';
$stylesheets2 = '';
for ($i=0;$i<$style_elements->length;$i++) {
$stylesheets .= $style_elements->item($i)->nodeValue . "\n";
if($i == 30) {break;}
}
$styles = '<style type="text/css" media="all">' . $stylesheets . "</style>\n";
for ($i=31;$i<$style_elements->length + 1;$i++) {
$stylesheets2 .= $style_elements->item($i)->nodeValue . "\n";
if($i == 60) {break;}
}
if($stylesheets2 != '') {
$styles .= '<style type="text/css" media="all">' . $stylesheets2 . '</style>';
}
$vars['styles'] = $styles;
?>
Initial URL
Initial Description
To be placed in template.php preprocess_page function.\\r\\n\\r\\nBreaks stylesheets into 2 style tags with limit of 30 @imports each. IE has a limitation of 31 @imports or 31 style tags. (source: [http://john.albin.net/ie-css-limits/single-style-test.html](http://john.albin.net/ie-css-limits/single-style-test.html))
Initial Title
Drupal Overcome IE 31 stylesheet limit
Initial Tags
ie, drupal
Initial Language
PHP