- Issue created by @msn5158
- 🇷🇺Russia Chi
Twig Tweak is for rendering content it does not provide helpers for loading entities anymore.
The entity field can be rendered as follows.
{{ drupal_field('created', 'node', 1) }}
- Status changed to Fixed
6 months ago 11:07am 21 July 2024 Thank you, As you said, it has obtained the creation time of the node by twig_tweak.
{{ drupal_field('created', 'node', 1) }}
But why can't it obtain the change time?
{{ drupal_field('changed', 'node', 1) }}
It doesn't print anything.
- 🇷🇺Russia Chi
drupal_field
renders field using formatter configured for a given display mode.
You need to enable this field in display settings. Alternatively you can pass formatter settings as argument to thedrupal_field
. I couldn't find the field about time in the Manage display, I don't know how to enable it.
- 🇷🇺Russia Chi
Changed field is not configurable for Nodes. You have to pass formatter options in Twig template.
{{ drupal_field('changed', 'node', 1, {type: 'timestamp', label: 'above', settings: {date_format: 'medium'}}) }} # Short version if you are happy with defaults. {{ drupal_field('changed', 'node', 1, {}) }}
I couldn't find any relevant tutorials here (https://git.drupalcode.org/project/twig_tweak/-/blob/3.x/docs/cheat-shee...), I don't know that can write the code like this.
Thank you very much, it's working ok.
Automatically closed - issue fixed for 2 weeks with no activity.