Tokens within Twig-Part or entity object

Created on 9 June 2017, over 7 years ago
Updated 21 September 2023, about 1 year ago

If I don't want to use PHP in coding a fomatter (Twig should be used), than I don't see a possibility yet to use field data with entity properties (I need title and entity id).

I need or tokens within Twig code or variables with the entity properties. May be I didn't understand how to access entity properties by object methods.

HTML+Token is not a solution here because I need a translation function (Twig |t or PHP t()).

✨ Feature request
Status

Active

Version

4.0

Component

Engine: Twig

Created by

πŸ‡©πŸ‡ͺGermany ksi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    I'm having trouble doing anything with a list of items in an entity reference.

    For example:

    <div class="tags">
    {% for item in items %}
      <span>#{{ item }}</span>
    {% endfor %}
    <div>

    The twig formatter is just rendering the twig as a template:

    $output = $twig_service->createTemplate($this->entity->data)->render([
      'items'    => $items,
      'langcode' => $langcode,
    ]);
    

    Is it possible to render it using the field theme instead?

Production build 0.71.5 2024