2

I've set up a custom content on my multilang site type with several fields that are all configured to be translatable. But when I try to theme that node I only habe a subset of the field available, although all the other field are saved in fieldDefinitions array. How to have all the fields available in fields array?

I have a node template node--products.html.twig Therein I access the values with {{ content.field_content_rating_level }} which works fine for the 4 fields in the fields array above, but not for the rest of theme even thought the share the same type of field. All fields are editable without any error in the backend. All fields are filled and translatable.

I use some of the missing fields in views and they work.

enter image description here

3
  • 2
    What are your "Manage display" settings? - Fields will be added to {{ content }} only, if they are configured visible within the display settings. You may also wish to debug available node fields in your template e.g. by using {{ dump(node|keys) }}, as the node variable holds the original node entity. Aug 12 '18 at 12:34
  • Thank you you were right: it applied a custom view mode beside default that i didn't recognized.
    – radscheit
    Aug 12 '18 at 13:13
  • 2
    Glad, I could be of help. - So I'll add a proper answer for future visitors of this question, once back on a PC. Aug 12 '18 at 13:26
4

The {{ content }} variable within node templates contains all fields configured to be visible within your content type's display settings. If you experience fields missing, they are most likely disabled within your display.

Head over to your administrative backend's Structure > Content types > [Your content type] > Manage display settings and ensure all fields you are trying to access are enabled for your current display mode.

You can always access disabled fields within your node templates by accessing the original node entity. The node entity along with its fields and some limited accessor methods are available within the {{ node }} variable of your templates.

Use e.g. {{ dump(node|keys) }} for debugging the available properties of the node within your template.

Comprehensive documentation about the variables within node templates can be found within it's header's comment block.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.