Skip to content

Instantly share code, notes, and snippets.

@ericjgruber
Created July 14, 2015 15:37
Show Gist options
  • Save ericjgruber/a4a1482e90428caa5539 to your computer and use it in GitHub Desktop.
Save ericjgruber/a4a1482e90428caa5539 to your computer and use it in GitHub Desktop.
Add a class to every page in Drupal 7
/**
* Implements hook_preprocess_htm().
*/
function THEME_preprocess_html(&$variables) {
$path = drupal_get_path_alias();
$aliases = explode('/', $path);
foreach($aliases as $alias) {
$variables['classes_array'][] = 'page-alias-' . drupal_clean_css_identifier($alias);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment