Two lists in one section.

Shopify Partner
1 0 0

Sorry for my poor english.

I have a dynamic list (e.g. product benefits).

I want to add a second dynamic list to a page in the same section (e.g. product facts).
I use a loop for this. But I have a problem. Something goes wrong and looping occurs.

That is, I add one item, I see one list, one item. I add the second element, I see two identical lists with two elements, etc.

Tell me how to do it right, thanks!

 

My code is:

      <div>
        {% for block in section.blocks %}
  	    {% if block.type == 'benefit' %}
    		<ul class="product__benefits">
                  {% for block in section.blocks %}
  			<li style="..."></li>
                  {% endfor %}
		</ul>
      	     {% endif %}
	{% endfor %}
      </div>
      
      <div>
        {% for block in section.blocks %}      
      	    {% if block.type == 'bullet' %}
      		<ul class="product-facts">
                   {% for block in section.blocks %}
          		<li class="product-facts__list-item">
            		   <span>...</span>
          		</li>
                   {% endfor %}
      		</ul>
  	    {% endif %}
{% endfor %} </div>
{% schema %}
{
  "name": "Sparkle: Header",
  "class": "sparkle-header",
  "tag": "section",

  "settings": [
    ...
  ],

  "blocks":[
    {
    "type": "benefit",
    "name": "Benefit",
    "settings": [
         {
            "id": "image",
            "type": "image_picker",
            "label": "Image"
          }
     ]
    },
  
    {
      "type": "bullet",
      "name": "Bullet Point",
      "settings": [
          {
              "id": "text",
              "type": "text",
              "label": "Text"
          }
       ]
     } 
  ],

  "presets": [
    ...
  ]
}
{% endschema %}
 

 

0 Likes