statamic / ideas

đŸ’¡Discussions on ideas and feature requests for Statamic
https://statamic.dev
30 stars 1 forks source link

Can't increment variable in collection loop #1041

Closed tobiv closed 9 months ago

tobiv commented 10 months ago

I want to set a variable that gets output and then incremented in a collection loop. Like this:

{{ $count = 1 }}
{{ collection:posts }}
    <span>{{ $count }}</span>
    {{ $count += 1 }}
{{ /collection:posts }}

This code ouputs 1 for every iteration though. Is there another way to do this?

Statamic v4.20.0

closed, Wrong repo …