문제

I have a custom block where I need to use [current-user:uid] in just one text. In Drupal 7, I would have used PHP input filter. How can I do this in Drupal 8?

도움이 되었습니까?

해결책

You may use twig bamboo or a preprocess function where you load the current user.

function hook_preprocess_HOOK(&$variables) {
  $vars['user'] = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 drupal.stackexchange
scroll top