Skip to content
Snippets Groups Projects

Issue #3466585 by Anybody, Grevil: Use a multidimensional render array to keep the original title and prefix / suffix it

Merged Issue #3466585 by Anybody, Grevil: Use a multidimensional render array to keep the original title and prefix / suffix it
Files
2
@@ -46,10 +46,16 @@ function taxonomy_term_title_ps_preprocess_page_title(&$variables) {
@@ -46,10 +46,16 @@ function taxonomy_term_title_ps_preprocess_page_title(&$variables) {
if ($title_prefix !== '' || $title_suffix !== '') {
if ($title_prefix !== '' || $title_suffix !== '') {
if (is_array($variables['title']) && !empty($variables['title']['#markup'])) {
if (is_array($variables['title']) && !empty($variables['title']['#markup'])) {
// Taxonomy terms use ['title']['#markup'] for their name:
// Titles can be render arrays:
$variables['title']['#markup'] = $title_prefix . $variables['title']['#markup'] . $title_suffix;
$originalTitle = $variables['title'];
 
// So we keep the array structure and the original contents.
 
$variables['title'] = [];
 
$variables['title'][] = ['#plain_text' => $title_prefix];
 
$variables['title'][] = $originalTitle;
 
$variables['title'][] = ['#plain_text' => $title_suffix];
}
}
else {
else {
 
// Or titles can be strings:
$variables['title'] = taxonomy_term_title_ps_generate($title_prefix, $variables['title'], $title_suffix);
$variables['title'] = taxonomy_term_title_ps_generate($title_prefix, $variables['title'], $title_suffix);
}
}
}
}
Loading