I created a view. I added the global counter variable field. On a field below the counter field I chose to rewrite the output. In this rewritten field, if I output the counter field using {{ counter }} I get the value I would expect. That is, I get an incremental number starting at 1 for each row in the view. When I try to use Twig in the rewrite field though to test if the counter value is greater than a certain number, like {% if counter > 1 %} for example, it does not work. After several testing, it appears that the counter is always equal to zero when testing it in a Twig if statement, even though it outputs an incremental number each time.


mattferderer created an issue. See original summary.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.