Skip to content

Instantly share code, notes, and snippets.

@hedleysmith
Created September 13, 2013 12:03
Show Gist options
  • Select an option

  • Save hedleysmith/6549790 to your computer and use it in GitHub Desktop.

Select an option

Save hedleysmith/6549790 to your computer and use it in GitHub Desktop.
Drupal 7 Spaces module: Add current space to body as a class
/*
* 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