Created
September 13, 2013 12:03
-
-
Save hedleysmith/6549790 to your computer and use it in GitHub Desktop.
Drupal 7 Spaces module: Add current space to body as a class
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 template_preprocess_html() | |
| */ | |
| function YOURTHEME_preprocess_html(&$variables, $hook) { | |
| // Get the current space and output as a class in the body for use elsewhere | |
| $space = spaces_get_space(); | |
| // Works for Taxonomy spaces | |
| if(!empty($space->term->name)) { | |
| // Format nicely | |
| $space_name = str_replace(' ','-', $space->term->name); | |
| $space_name = str_replace('.','', $space_name); | |
| $variables['classes_array'][] = 'space-'. $space_name; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment