2016-11-24 8 views
0

Shopify製品のループ内で4つの製品の後ろに水平ブレイクを追加する方法を理解しようとしています。これはまったく可能ですか?私は彼らの文書を見てきましたが、ループを数えたり繰り返したりする可能性は示されていません。次のようにShopify 4つの製品の後ろに水平ブレイクを追加する

現在、私のループが見えます:

{% if collection.all_products_count > 0 %} 
    <div class="w-col w-col-12"> 
    <div class="product-feed w-clearfix"> 
     {% for product in collection.products %} 
      <a class="product product-collection w-inline-block" href="{{ product.url | within:collection }}"> 
      <div class="reveal"> 
       <img src="{{ product.featured_image | product_img_url: 'original' }}" alt="{{ product.title | escape }}" class="product-photo"> 
       <img src="{{ product.images.last | product_img_url: 'original' }}" alt="{{ product.title | escape }}" class="hidden"> 
      </div> 
      <h3 class="product-title">{{ product.title }}</h3> 
      <div class="product-price">{{ product.price | money }}</div> 
      <span class="shopify-product-reviews-badge" data-id="{{ product.id }}"></span> 
      </a> 
     {% endfor %} 
    </div> 
    {% assign count = paginate.pages %} 
     {% for part in (1..count) %} 
     <li {% if paginate.current_page == part %}class="active"{% endif %}><a href="{{ collection.url }}?page={{ forloop.index }}">{{ forloop.index }}</a></li> 
     {% endfor %} 
    {% else %} 
    <p>Sorry, there are no products in this collection</p> 
    {% endif %} 

答えて

1

それはあなたが適切に文書化を経ていない公正な説明です。これを参照してください: - 仕事にこれを取得するhttps://help.shopify.com/themes/liquid/objects/for-loops

ストレートな方法は、あなたが

<hr>を好む場合{% endfor %}

{% cycle '','','','<hr>' %} //または<br>前に次の行を追加しているforloopが反復されるたびに追加されます4回目。もっと詳しく - https://help.shopify.com/themes/liquid/tags/iteration-tags#cycle

関連する問題