This commit is contained in:
Bachir Soussi Chiadmi 2024-04-19 17:55:01 +02:00
parent 97b7d0396f
commit 842b220b1d
1 changed files with 15 additions and 7 deletions

View File

@ -26,17 +26,25 @@ function erabletheme_preprocess_node(&$variables) {
$t = "t";
}
function erabletheme_preprocess_node__view__meetup(&$variables) {
/** @var \Drupal\node\Entity */
/** @var \Drupal\node\Entity $node */
$node = $variables['node'];
$user_id = $node->get('uid')->getValue()[0]['target_id'];
/** @var Drupal\user\Entity */
/** @var Drupal\user\Entity $user*/
$user = \Drupal\user\Entity\User::load($user_id);
/** @var Drupal\profile\Entity */
/** @var Drupal\profile\Entity $profile */
$profile = $user->get('candidat' . '_profiles')->entity;
$variables['profile'] = [
'nom' => $profile->get('field_nom')->getValue()[0]['value'],
'prenom' => $profile->get('field_prenom')->getValue()[0]['value']
];
if ($profile) {
$variables['profile'] = [
'prenom' => $profile->get('field_prenom')->getValue()[0]['value'],
'nom' => $profile->get('field_nom')->getValue()[0]['value']
];
} else {
$variables['profile'] = [
'prenom' => $user->getAccountName(),
'nom' => "",
];
}
}
/**