【问题标题】:Chose which (shopify) collection to loop through with schema in liquid?选择哪个(shopify)集合以液体模式循环?
【发布时间】:2016-12-07 02:20:15
【问题描述】:

因此,我尝试遍历 shopify 商店用户可以在设置中选择的集合。现在,如果我分配某个集合,那么一切正常,但这不允许我动态更改它。

<div id="slideshow">
  <div class="wrapper">
    <div class="rslides_container">
        <ul class="rslides" id="slider1">
            {% assign _collection = collections['new-products'] %}
            {% for product in _collection.products %}
              <li class="slideshow-item">
                  <a href="{{ product.url }}"><img src="{{  product.featured_image | img_url: 'medium' | format: 'jpg' }}" alt="{{ block.settings.slide_heading }}"></a>            
                  <h3>{{ product.title }}</h3>
                  <h4>{{ product.price | money | remove: '.00' }}</h4>
                  <p>{{ product.description }}</p>
                  {% include 'buybutton' %}
              </li>

            {% endfor %} 
            </ul>
        </div><!-- #slideshow-container -->
    </div>
</div><!-- #slideshow -->
{% schema %}
  {
    "name": "Slideshow",
    "settings": [
        {
            "type": "collection",
            "id": "feature_collection",
            "label": "Chose Collection to show on slideshow"
        }
    ]
  }
{% endschema %}

我想将 for 循环更改为:

 {% for product in collections[settings.feature_collection].products %}

会起作用,但无论我在主题定制器中选择什么集合,它都不会在滑块上显示任何内容。有没有人这样做或知道怎么做?谢谢!

【问题讨论】:

    标签: html loops schema shopify liquid


    【解决方案1】:

    我想通了。我在循环语句中省略了一部分。

    {% for product in collections[section.settings.feature_collection].products %}
    

    我在 .settings 之前缺少单词部分

    【讨论】:

      【解决方案2】:

      我会试试的。

      {% for product in collection.feature_collection.product%}

      【讨论】:

      • 我要删除assign标签吗?
      • 没有,那没用..它现在在滑块中什么都没有显示
      猜你喜欢
      • 1970-01-01
      • 2020-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多