skip to Main Content

This error is because of the code written with incorrect syntax below. Could you please help fix the syntax error at those two lines in it?

{% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
{% if forloop.last || forloop.index | modulo: 3 == 0 %}


<div class="impact-items">
 {% for block in section.blocks %}
  {% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
  <div class="impact-content col-xs-12 col-md-4">
   <div class="impact-icon"><img src="{{block.settings.impact_icon | img_url: 'master' }}"></div>
   <div>
    <div class="impact-number">{{block.settings.impact_number}}</div>
    <div class="impact-text">{{block.settings.impact_text}}</div>
   </div>
  </div>
  {% if forloop.last || forloop.index | modulo: 3 == 0 %}
   </div>
  {% endif %}
 {% endfor %}
 <div class="row">
  <div class="mt2x btn center-xs col-sm-12 col-md-12 col-lg-12 col-xl-12"><a href='https://packedwithpurpose.gifts/our-impact/impact-report-2020/'><button>Learn More About our Impact</button></a></div>
 </div> 
</div>

2

Answers


  1. Chosen as BEST ANSWER
        {% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
        {% if forloop.last || forloop.index | modulo: 3 == 0 %}
        <div class="impact-items">
         {% for block in section.blocks %}
        {% modulo = forloop.index0 | modulo: 3 %}
          {% if modulo == 0 %}<div class="row">{% endif %}
          <div class="impact-content col-xs-12 col-md-4">
           <div class="impact-icon"><img src="{{block.settings.impact_icon | img_url: 'master' }}"></div>
           <div>
            <div class="impact-number">{{block.settings.impact_number}}</div>
            <div class="impact-text">{{block.settings.impact_text}}</div>
           </div>
          </div>
          {% if forloop.last || forloop.index | modulo: 3 == 0 %}
           </div>
          {% endif %}
         {% endfor %}
         <div class="row">
          <div class="mt2x btn center-xs col-sm-12 col-md-12 col-lg-12 col-xl-12"><a href='https://packedwithpurpose.gifts/our-impact/impact-report-2020/'><button>Learn More About our Impact</button></a></div>
         </div> 
        </div>
    
    {% endif %}
    

  2. You’re missing closing If statement at the end. {% endif%}

    Here is the complete code with no error –

    {% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
    {% if forloop.last || forloop.index | modulo: 3 == 0 %}
    <div class="impact-items">
     {% for block in section.blocks %}
      {% if forloop.index0 | modulo: 3 == 0 %}<div class="row">{% endif %}
      <div class="impact-content col-xs-12 col-md-4">
       <div class="impact-icon"><img src="{{block.settings.impact_icon | img_url: 'master' }}"></div>
       <div>
        <div class="impact-number">{{block.settings.impact_number}}</div>
        <div class="impact-text">{{block.settings.impact_text}}</div>
       </div>
      </div>
      {% if forloop.last || forloop.index | modulo: 3 == 0 %}
       </div>
      {% endif %}
     {% endfor %}
     <div class="row">
      <div class="mt2x btn center-xs col-sm-12 col-md-12 col-lg-12 col-xl-12"><a href='https://packedwithpurpose.gifts/our-impact/impact-report-2020/'><button>Learn More About our Impact</button></a></div>
     </div> 
    </div>
    {% endif %}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search