Score:0

Preprocessing view if grouping is enabled

sa flag

Views has base template views-view-unformatted.html.tpl with contents:

{% if title %}
  <h3>{{ title }}</h3>
{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  <div{{ row.attributes.addClass(row_classes) }}>
    {{- row.content -}}
  </div>
{% endfor %}

Where variable {{ title }} - mean The title of this group of rows. It's usually empty.

So, I want to preprocess this template in my .theme file and override this {{ title }} variable (or assign new) with my contents for this view if grouping enabled.

Grouping enabled

berliner avatar
bd flag
Welcome to Drupal Answers! What's the question/problem?
sa flag
@berliner Question in last paragraph: I want preprocess {{title}} variable in this template. I want change {{title}} contents for each group. I wasn't doing this in template because required do some php actions.
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.