Last active
August 29, 2015 14:22
-
-
Save opi/df0b6429cfabe41b1dca to your computer and use it in GitHub Desktop.
Drupal : Global class for long text elements
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
<?php | |
/** | |
* Implements template_preprocess_field(). | |
*/ | |
function EXAMPLE_preprocess_field(&$vars) { | |
/* | |
* theme_hook_suggestion: | |
* $variables['theme_hook_suggestions'] = array( | |
'field__' . $element['#field_type'], | |
'field__' . $element['#field_name'], | |
'field__' . $element['#bundle'], | |
'field__' . $element['#field_name'] . '__' . $element['#bundle'], | |
); | |
* ex: field__field_faq_question | |
* ex: field__field_faq_question__field_faq (here, bundle = field_collection field | |
* ex: field__field_faq_answer | |
*/ | |
$element = $vars['element']; | |
// Global class for long text elements | |
$field_type_text = array( | |
'text', | |
'text_long', | |
'text_with_summary', | |
'paragraphs' // Not always | |
); | |
if (in_array($element['#field_type'], $field_type_text)) { | |
$vars['classes_array'][] = 'text-field'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment