- 🇦🇹Austria plepe
I extended the module by twig templates. There's a switch in the configuration, where you can select between tokens or twig templates. I haven't created a patch (yet), for now it is available on Github.
Examples, how you can use it:
{{ entity.field_name[0].value }}
{% for v in entity.field_name %}{{ v.value|upper }} {% endfor %}
- 🇫🇷France GuillaumePacilly
I had the same need and solved it by using custom tokens. Then you can apply conditions inside your hook_tokens().
/** * Implements hook_token_info(). */ function mymodule_token_info() : array { $info = []; $info['types']['my_custom_tokens'] = [ 'name' => t('Custom Tokens'), 'description' => t('Tokens available for specific use on this website'), ]; $info['tokens']['my_custom_tokens']['custom_token'] = [ 'name' => 'Custom token', 'description' => t('Custom token with conditions'), ]; return $info; } /** * Implements hook_tokens(). */ function mymodule_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) : array { $replacements = []; if ($type == 'my_custom_tokens') { foreach ($tokens as $name => $original) { switch ($name) { case 'custom_token': $node = $data['node']; // Add your logic here. $replacements[$original] = $title; } break; default: break; } } } return $replacements; }
Then just use your custom token in the auto_entitylabel configuration