Created
February 7, 2014 19:10
-
-
Save Greg-Boggs/8869659 to your computer and use it in GitHub Desktop.
Group Drupal CSS
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_css_alter(). | |
*/ | |
function mymodule_css_alter(&$css) { | |
uasort($css, 'drupal_sort_css_js'); | |
$i = 0; | |
foreach ($css as $name => $style) { | |
$css[$name]['weight'] = $i++; | |
$css[$name]['group'] = CSS_DEFAULT; | |
$css[$name]['every_page'] = FALSE; | |
} | |
} | |
?> | |
<?php | |
//if you have more than 4095 selectors here's the method to make two sheets for IE 8 | |
uasort($css, 'drupal_sort_css_js'); | |
$i = 0; | |
foreach ($css as $name => $style) { | |
$css[$name]['weight'] = $i++; | |
// Break grouping into two sets - CSS_SYSTEM, (-100) and the rest | |
if ($style['group'] == -100) { | |
$css[$name]['group'] = CSS_SYSTEM; | |
} | |
else { | |
$css[$name]['group'] = CSS_DEFAULT; | |
} | |
$css[$name]['every_page'] = FALSE; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment