How to render particular field value in htmlpdf.html.twig template file

Created on 28 June 2017, over 7 years ago
Updated 23 July 2024, 4 months ago
💬 Support request
Status

Closed: works as designed

Component

Code

Created by

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 Kingdom David Fiaty

    "Entity PDF allows you to chose a view mode" => How to select a view mode to be rendered as PDF?

  • 🇬🇧United Kingdom matt b

    Just in case anyone comes across this... all you really seem to have in the htmlpdf.html.twig template is the {{ title }} and {{ content }} variables - I guess because we're dealing with the rendered PDF, not with theming entity.

    However, it is possible to do more with the twig_tweak module . With this I can get the node ID and then render a specific field from that node. It's probably not the best way... but it gets the job done.

        {% set nid=drupal_token('current-page:url:args:value:2')%}
        <p>{{ drupal_field('field_author', 'node', nid) }}</p>
Production build 0.71.5 2024