function html_title_preprocess_field__node__title in HTML Title 8
Implements hook_preprocess_HOOK().
File
- ./
html_title.module, line 81 - HTML Title module to enable limited HTML tags in title.
Code
function html_title_preprocess_field__node__title(&$vars) {
if ($vars && !empty($vars['field_name']) && $vars['field_name'] === 'title' && $vars['entity_type'] === 'node') {
if (is_array($vars['items']) && !empty($vars['items'])) {
foreach ($vars['items'] as $key => $value) {
if (isset($vars['items'][$key]['content']['#context']['value'])) {
$item_text = $vars['items'][$key]['content']['#context']['value'];
$vars['items'][$key]['content']['#context']['value'] = \Drupal::service('html_title.filter')
->decodeToMarkup($item_text);
}
}
}
}
}