function show_title_taxonomy_term_view in Show title 2.0.x
Same name and namespace in other branches
- 8 show_title.module \show_title_taxonomy_term_view()
Implements hook_ENTITY_TYPE_view().
File
- ./
show_title.module, line 99 - Module Show Title.
Code
function show_title_taxonomy_term_view(array &$build, EntityInterface $taxonomy_term, EntityViewDisplayInterface $display, $view_mode) {
$langcode = \Drupal::languageManager()
->getCurrentLanguage()
->getId();
if ($display
->getComponent('show_title')) {
// Add attributes for quickedit.
$attributes = [
'data-quickedit-field-id' => 'taxonomy_term/' . $taxonomy_term
->id() . '/name/' . $langcode . '/' . $view_mode,
'class' => 'field field--name-name-text field--type-string quickedit-field quickedit-candidate quickedit-editable',
];
$build['show_title'] = [
'#type' => 'markup',
'#markup' => '<div' . new Attribute($attributes) . '>' . $taxonomy_term
->getName() . '</div>',
];
}
}