0

I'm on D10.1.x.

I need to add a current-user:xx token inside a column of a view.

I've seen that by default, the token replacement doesn't work, e.g. if I use [current-user:mail, the token is not replaced.

I've tried the workaround described here, however it doesn't work, as I get the error:

Twig\Error\SyntaxError: Unknown "drupal_token" tag in "__string_template__d63e10f79d9d43968f5ae212f85498f7" at line 1. in Twig\Parser->subparse() (line 160 of /var/www/html/vendor/twig/twig/src/Parser.php).

Any idea\suggestion on how I could implement that, or how implement this workaround? Thanks.

2
  • Tested D10.2.1 and twig_tweak 3.2.1. drupal_token works, with a token for the site name and the current user mail. Please try this on a fresh install and provide more info how to reproduce the error. If you get it working you still have a problem with caching, a views field is usually not cached by user.
    – 4uk4
    Jan 11 at 13:02
  • @4uk4 sorry for the late reply, but I had no time to check this again. At the time of your comment I too just tried with a clean D10 install and saw it worked. However, I don't know why, but after the last core updates - currently the site is on 10.1.8 - I can't replicate anymore the error. Aka, I can place a token inside a view field using twig tweak drupal_token function. Thanks for the check nevertheless.
    – Giuseppe
    Jan 23 at 14:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.