Created
October 15, 2012 13:01
-
-
Save hannesl/3892343 to your computer and use it in GitHub Desktop.
Override a stylesheet added by a Drupal 7 theme
This file contains hidden or 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_element_info_alter(). | |
| */ | |
| function mymodule_element_info_alter(&$type) { | |
| // Rather than implementing hook_css_alter(), we'll add a custom pre render | |
| // function for the styles elemement. This is to allow us to override | |
| // seven_css_alter(), which always runs after any module's implementation. | |
| if (isset($type['styles']['#pre_render'])) { | |
| array_unshift($type['styles']['#pre_render'], 'mymodule_pre_render_styles'); | |
| } | |
| } | |
| /** | |
| * Pre render the styles element. | |
| */ | |
| function mymodule_pre_render_styles($elements) { | |
| $css = &$elements['#items']; | |
| // Installs the jquery.ui themeroller theme to the theme. | |
| if (isset($css['misc/ui/jquery.ui.theme.css'])) { | |
| $css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('module', 'mymodule') . '/css/mymodule-jquery-ui-theme.css'; | |
| } | |
| if (isset($css['misc/ui/jquery.ui.dialog.css'])) { | |
| unset($css['misc/ui/jquery.ui.dialog.css']); | |
| } | |
| if (isset($css['misc/ui/jquery.ui.tabs.css'])) { | |
| unset($css['misc/ui/jquery.ui.tabs.css']); | |
| } | |
| return $elements; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A Drupal 7 theme can implement hook_css_alter() to insert custom css files in place of those added by modules. Seven in core does this to add its own jQuery UI styles for example. But sometimes you just need to override the override...