0

I have a translation problem on my site in drupal 9.1.3.

I have a content type for my homepage that contains two fields: field_slides which is an EntiyReferenceRevisionFieldItemList to a Paragraphs field and field_tabulations which is an EntityReferenceFieldItemList to a "tab" content type.

This type of content contains 4 fields including a Paragraphs field.

My configuration in admin / config / regional / content-language is correct. And I only enabled translation for child paragraphs fields as said in the documentation.

In the template I call the title field of the entity referenced by field_tabulations as follows:

{{ elements['field_tabulations']['# items'].0.entity.title.0.value }}

However, the home page node fields in my template front page are not translated. The blocks are, however as the main menu is.

4
  • 3
    "Cross-entity rendering" (e.g. something like {{ some_entity.some_field.0.entity.whatever }}) in templates is neither cache-safe nor language-safe. Anything behind a .entity should be considered outside the scope of the current template. Better use the proper paragraph and field templates instead. – Hudri Jan 26 at 16:08
  • Many thanks @Hudri! I can't figure out how to get a field not passing through the entity. – Frédéric Hébert Jan 26 at 20:09
  • Ideally you shouldn't pass field values between templates, but render them in parent with {{ content.field_foo }} and in the child template do the proper formatting. – Hudri Jan 27 at 8:15
  • yes. But in this case the field is only available on the entity afaik. I will look forward. Many thanks – Frédéric Hébert Jan 28 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.