Score:0

Creating twig template for rows in a specific view

kp flag

Hi I have a view with the machine name news_filter. In the html every content type it's fields are inside a .views-row div. I want to create a template for those specific rows and maybe later also for each field too. But I can't find the right naming conventions to do so.

Does anyone have an idea?

4uk4 avatar
cn flag
For the Views style *Unformatted* see https://drupal.stackexchange.com/questions/310155/twig-template-for-specific-node-view. Turn on Twig Debug if you are unsure how your View is configured and which Twig templates are used.
Score:0
uz flag

The template name would be views-view-unformatted--news-filter.html.twig, do clear the cache after adding the template file.

In views you cloud use a display with rendered entity display (Content) and a specific viewmode, use the template suggestion for the entity type, e.g. node--news--VIEWMODE.html.twig.

#views-view-unformatted--news-filter.html.twig
{% for row in rows %}
    {{- row.content -}}
{% endfor %}
#node--news--VIEWMODE.html.twig
<div class="news-item">
  <a href="{{ path('entity.node.canonical', {'node': 393}) }}?sort={{ node.id }}" class="use-ajax"
     data-dialog-type="full_screen">
    <article>
      {{ content.field_event_datum }}
      <h3>{{ label }}</h3>
    </article>
    <div class="click"><p>weiterlesen ></p></div>
  </a>
</div>
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.