Skip to content

Instantly share code, notes, and snippets.

@ghorvat
Created January 19, 2016 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ghorvat/a28a489055bf8eb325a8 to your computer and use it in GitHub Desktop.
Save ghorvat/a28a489055bf8eb325a8 to your computer and use it in GitHub Desktop.
foreach ($items as $delta => $item) {
// suppress all children so this field is not rendered
if ($field['type'] == 'list_boolean') {
$classes_array[] = drupal_html_class($field['settings']['allowed_values'][$item['value']]);
}
elseif ($field['type'] == 'taxonomy_term_reference') {
$tids[] = $item['tid']; //store the terms ids and just do taxonomy_term_load_multiple once at the end
}
else {
$classes_array[] = drupal_html_class($item['value']);
}
}
@ghorvat
Copy link
Author

ghorvat commented Jan 19, 2016

function drupal_html_class($class) {
// The output of this function will never change, so this uses a normal
// static instead of drupal_static().
static $classes = array();

if (!isset($classes[$class])) {
$classes[$class] = drupal_clean_css_identifier(drupal_strtolower($class));
}
return $classes[$class];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment