Convert user ID to user display name for blog views
This commit is contained in:
parent
1f9714463f
commit
6306d84c6d
1 changed files with 18 additions and 0 deletions
18
web/themes/custom/geofresco/geofresco.theme
Normal file
18
web/themes/custom/geofresco/geofresco.theme
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Preprocess functions for GEO site.
|
||||
*/
|
||||
function geofresco_preprocess_page_title(&$variables) {
|
||||
// WE SHALL BE SHAMELESS.
|
||||
$string = isset($variables['title']['#markup']) ? $variables['title']['#markup'] : FALSE;
|
||||
if ($string && $pos = strpos($string, "'s blog", -7)) {
|
||||
$uid = substr($string, 0, $pos);
|
||||
if (is_numeric($uid) && $account = \Drupal\user\Entity\User::load($uid)) {
|
||||
$variables['title'] = [
|
||||
'#markup' => t("@username's blog",
|
||||
['@username' => $account->getDisplayName()])
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue