a counter to a view grouping

Created on 1 August 2023, 11 months ago
Updated 12 December 2023, 7 months ago

I have a view and It added fields in groups and overide view grouping twig template

{#
/**
 * @file
 * Theme override to display a single views grouping.
 *
 * Available variables:
 * - view: The view object.
 * - grouping: The grouping instruction.
 * - grouping_level: A number indicating the hierarchical level of the grouping.
 * - title: The group heading.
 * - content: The content to be grouped.
 * - rows: The rows returned from the view.
 *
 * @see template_preprocess_views_view_grouping()
 */
#}
<div class="view-grouping-header " data-id="item-{{ counter }}">{{ title }}</div>
<div class="view-grouping-content">{{ content }}</div>

counter variable should append the number of time grouping accrues. let say in my case there are 5 times grouping. So i counter add 1,2,3,4,5 oneach grouping

<div class="view-grouping-header " data-id="item-1">{{ title }}</div>
<div class="view-grouping-content">{{ content }}</div>

<div class="view-grouping-header " data-id="item-2">{{ title }}</div>
<div class="view-grouping-content">{{ content }}</div>

<div class="view-grouping-header " data-id="item-3">{{ title }}</div>
<div class="view-grouping-content">{{ content }}</div>

<div class="view-grouping-header " data-id="item-4">{{ title }}</div>
<div class="view-grouping-content">{{ content }}</div>

<div class="view-grouping-header " data-id="item-5">{{ title }}</div>
<div class="view-grouping-content">{{ content }}</div>
πŸ’¬ Support request
Status

Closed: cannot reproduce

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated 34 minutes ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024