液体中标签的父子列表

时间:2019-02-12 20:50:31

标签: shopify parent-child liquid

嗨,我是液体的新手,我在为分配给它们的收藏夹下显示相应的产品标签感到很苦恼。我设法在边栏中显示了相应的标签,但前提是我必须将第二个代码段粘贴在第一个代码段之后。但是我想以某种方式将标签显示为子项,将活动集合显示为父项

我知道它一定很简单,但是我被困在黑暗中。

在结尾处的第一个摘录中,我已经 标记了,其中在<ul>列表之外的第二个摘录已经有效

{% if settings.categories_block_enable %}
<div id="categories_block" class="block">
{% if settings.categories_block_title != blank %}
    <h4 class="title_block">{{ settings.categories_block_title }}</h4>
{% endif %}
<div class="block_content">
    <ul class="list-block list-group list-unstyled">
        {% if settings.categories_block_style == 'show_all' %}
            {% for category in collections limit:settings.categories_block_number %}
                <li {% if collection.handle == category.handle %} class="active" {% endif %}>
                    <a href="{{ category.url }}" title="{{ category.title }}">
                        {{ category.title }}
                        {% if settings.categories_block_productcount %}
                            {% if category.all_products_count > 0 %}
                                <span id="leo-cat-{{ category.id }}" class="leo-qty pull-right">{{ category.all_products_count }}</span>
                            {% endif %}
                        {% endif %}
                    </a>
                </li>
            {% endfor %}
        {% else %}
            {% assign category_items = settings.categories_block_items | split:"," | strip | downcase %}
            {% for category in category_items %}
                {% for category_site in collections %}
                    {% assign cat = category_site.title | downcase %}
                    {% if category contains cat %}
                        <li {% if collection.handle == category_site.handle %} class="active" {% endif %}>
                            <a href="{{ category.url }}" title="{{ category_site.title }}">
                                {{ category_site.title }}
                                {% if settings.categories_block_productcount %}
                                    {% if category_site.all_products_count > 0 %}
                                        <span id="leo-cat-{{ category_site.id }}" class="leo-qty pull-right">{{ category_site.all_products_count }}</span>
                                    {% endif %}
                                {% endif %}
                            </a>
                        </li>
                    {% endif %}
                {% endfor %}
            {% endfor %}
        {% endif %}
    </ul>
<!-- IF I PASTE SECOND SNIPPET HERE, THE CHILD TAGS CORRESPONDING TO THE ACTIVE COLLECTION ARE SHOWED IN A SEPERATE LIST -->
  </div>
</div>
{% endif %}

第二个代码段显示了相应的标签:

 <ul class="subnav clearfix">
        {% for tag in collection.all_tags %}
        {% if current_tags contains tag %}
          <li class="active">
            {{ tag | link_to_remove_tag: tag }}
          </li>
        {% else %}
          <li>
            {{ tag | link_to_tag: tag }}
          </li>
        {% endif %}
        {% endfor %}
  </ul>

0 个答案:

没有答案