This PHP tutorial will help you to implement a set of incremental variable in twig which you can use to show listing in twig with numbers in the first column. This will include defining twig variable and increment/decrements variable value in twig. lets see how, with the help of below code:
{% set inc = 1 %}
{% for value in communities %}
<tbody>
<tr>
<td>{{inc}}</td> <!-- HERE WE ARE SHOWING INCREMENTED NUMBER -->
<td>{{value.community_description}}</td>
<td><img src="{{value.community_photo_one}}" height="75" width="100"></td>
<td>{{value.created_on}}</td>
<td><a href="/admin/update_community?id={{value.id}}"><button class="btn btn-round btn-primary" type="button">Update</button></td>
</tr>
</tbody>
{% set inc = inc + 1 %}
{% endfor %}
1 Comment(s)