How to get book field values?

Created on 17 January 2023, over 1 year ago
Updated 20 November 2023, 10 months ago

Problem/Motivation

How to get the values of the parent node field_gold using twig in page.html.twig
on the child page. [node:book:root:field_god:0] get this result only via twig in page.html.twig

Steps to reproduce

Proposed resolution

{{ node.book.field_god.value }} what is the correct solution to get the field value in page.html.twig ?)

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

💬 Support request
Status

Closed: outdated

Version

9.5

Component
Field 

Last updated 1 day ago

Created by

🇷🇺Russia acakyra

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.

  • Status changed to Postponed over 1 year ago
  • Status changed to Active over 1 year ago
  • 🇺🇸United States cilefen

    Unfortunately, there has been no response to this support request. I updated the title to English.

    Timely responses to support requests in the Drupal core issue queue are rare. There are better forums for questions such a slack or stack exchange. I encourage you to try them.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Rohit Rana

    try this
    {{ node.getParentNode().field_gold.value }}

  • 🇮🇳India Raveen Kumar

    @acakyra, you can use something like this.

    {% if node.isTranslation %}
    {% set parentNode = node.getTranslation(node.source.langcode) %}
    {% else %}
    {% set parentNode = node %}
    {% endif %}

    {% if parentNode.field_gold %}
    {{ parentNode.field_gold.value }}
    {% endif %}

    And Thank You.

  • Status changed to Postponed: needs info over 1 year ago
  • 🇺🇸United States smustgrave

    @acakyra is there anything else you need from this if it can be closed out?

  • Status changed to Closed: outdated 10 months ago
  • 🇺🇸United States cilefen

    I am closing this issue due to inactivity. Reopen it as necessary.

Production build 0.71.5 2024