geo-coop/web/themes/custom/geofresco/geofresco.theme

23 lines
719 B
Text
Raw Normal View History

<?php
/**
* Preprocess functions for GEO site.
*/
function geofresco_preprocess_page_title(&$variables) {
// WE SHALL BE SHAMELESS.
if (!isset($variables['title']) || !is_array($variables['title'])) {
// The pages we're interested in have title as markup, so bail if it's not.
return;
}
$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()])
];
}
}
}