Last active
January 11, 2016 22:53
-
-
Save Codenator81/24fb83522b6740f1f624 to your computer and use it in GitHub Desktop.
Drupal 8 - Add to views field link class when fields is taxonomy referenced entity
This file contains 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
// Drupal 8 developper http://codenator.org | |
function THEMENAME_preprocess_views_view_field__field_tags(&$vars) { | |
$rendered = $vars['field']->getItems($vars['row']); | |
//added icon on front of tags | |
$renderedArray[] = [ | |
'#markup' => '<span class="glyphicon glyphicon-tags" aria-hidden="true"></span>' | |
]; | |
if (is_array($rendered)) { | |
foreach ($rendered as $one) { | |
//dpm($one['rendered']); | |
$one['rendered']['#attributes'] = [ | |
'class' => [ | |
'btn', | |
'btn-xs', | |
'btn-default', | |
'btn-tags' | |
] | |
]; | |
$renderedArray[] = $one['rendered']; | |
} | |
} | |
$vars['output'] = $renderedArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment