- Issue created by @plato1123
- π·πΊRussia Chi
Note the third parameter of
drupal_field()
. It must be ID of the node. When previewing a new node the ID is NULL because the node is not saved to database yet. If you have access tonode
object in your template, it's always better to useview
filter instead.Example:
{{ node.body|view}} {{ node.field_announcement|view }}
- Status changed to Closed: duplicate
over 1 year ago 7:48pm 8 June 2023 - πΊπΈUnited States plato1123
Just to confirm, there is a problem even when this node has already been saved. This breaks the ability to preview and instead of seeing a preview the editor sees the last saved copy. What's more there is no error message but the preview is broken. Because there was no error it took quite some time to track this problem down to twigtweak.
PS it seems like in this circumstance I can get away with using
{{ content.body }}
and
{{ content.field_announcement }}Thanks so much for your help!!!
- π·πΊRussia Chi
a preview the editor sees the last saved copy.
That is expected behavior.
drupal_field
always loads node from database, it does not care of what you are previewing.
This function is typically used when thenode
variable is not available. Otherwise{{ node.field_NAME|view }}
is preferable way to render a node. - πΊπΈUnited States plato1123
Awesome, I appreciate your fast reply and for upping my twig game!