Output individual fields only

Created on 7 February 2020, almost 5 years ago
Updated 18 February 2024, 9 months ago

I would really like to be able to render fields separately so that I can put them in different places on my template.

I tried so many possibilities but I just can't make it work.

{{ item.content['#menu_link_content'] }}
{{ item.content.field_menu_link_options|render }}
{{ item.content['#menu_link_content'].field_menu_link_options|render }}
{{item.entity.field_menu_link_options|raw}}
{{item.entity.field_menu_link_options.value}}
{{item.entity.field_menu_link_options|field_value}}
{{item.entity.field_menu_link_options|render|render}}
{{item.entity.field_menu_link_options.0}}

Could you please help me?

Feature request
Status

Fixed

Version

1.0

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.

  • 🇮🇹Italy fralenuvole

    Hello,

    thank you for your module.
    I am following your instructions in the last comment, and I am able to extract and render my custom field {{ content.field_example }}.
    Also {{ content|without('field_example') }} renders the title, but already linked.

    I need to have the menu title and URI separately, because I want to wrap both {{ content.field_example }} and {{ MENU_TITLE }} in the link (in my case content.field_example renders an SVG icon).

    Could you tell me how to extract the MENU_URL and MENU_TITLE separately, in order to have the following format?
    {{ content.field_example }}{{ MENU_TITLE }}

    Kind regards,
    Francesco

Production build 0.71.5 2024