Drupal 8 name of twig: views-view-grid--places.html

I'm extremely new to Drupal so bare with me and excuse any incorrect lingo.

I created a content type called places and added 2 fields (body and field_location). title is a default for fields.

In my view twig, how do I get those values in my for loop?

{% for item in items %}
        <div>{{ item.title }}</div>
        <div>{{ item.field_location }}</div>
        <div>{{ item.content }}</div>
{% endfor %}

This only outputs the body. What am I missing?


Use {{ dump(item) }} to see the structure.

Once you have the structure you can reference in a faily regular way: if a sub-item is an array or an object, then it's a dot, if an array with a #, reference as an array eg xxx.yyy['#zzz']

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.