Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set increment variable in twig?

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 5.68k
    Comment on it

    Hello Friends

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: