Global: View Result Counter does not evaluate properly in IF statements

Created on 12 July 2016, about 9 years ago
Updated 10 May 2023, over 2 years ago

I am trying to print something in row 1 only

Putting this in re-write field OR global: custom text field

{% if counter == 1 %}

This should be printing in row 1

{% endif %}

Does not return/print anything.

If I do != it prints "This should be printing in row 1" in row 1 and row 2.

Strangely, when I use a template file. Ex: views-view-fields.html.twig

{% if fields.counter.content == 1 %}

This should be printing in row 1

{% endif %}

I get the opposite result. Using == prints "This should be printing in row 1" in row 1 and row 2

and when I use != nothing gets printed.

I also unchecked all the boxes that add extra divs/markup from the views UI and same result.

πŸ› Bug report
Status

Active

Version

9.5

Component
ViewsΒ  β†’

Last updated 10 days ago

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024