Created
September 3, 2013 18:57
-
-
Save tmbritton/6428077 to your computer and use it in GitHub Desktop.
Drupal add classes to <body> tag based on taxonomy terms.
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_preprocess_html(). | |
* Add classes to <body> tag based on taxonomy terms. | |
*/ | |
function wfm_static_preprocess_html(&$vars) { | |
$node = node_load(arg(1)); | |
if ($node && $node->type === 'page') { | |
if (count($node->field_body_classes) > 0) { | |
foreach ($node->field_body_classes[LANGUAGE_NONE] as $term) { | |
$machine_name = drupal_html_class($term['taxonomy_term']->name); | |
$vars['classes_array'][] = $machine_name; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment