Shopify 有没有办法在列表中对 "Collections" 进行分类?
Is there way in Shopify to categorize "Collections" in lists?
假设我想在 Shopify 的 2 个不同页面上显示 2 个不同的 collection 列表(只是标题及其相关页面的链接); Shopify 中有什么方法可以做到吗?据我所知,我要么在页面上显示所有 "Collections",要么根本显示 none。是否没有选项可以对它们进行分类,以便我可以使用 liquid 仅显示某些 collections?
我发现的唯一其他选择是对页面上的 collection 菜单进行硬编码。但问题是,我创建的任何新 collection,如果我想显示它,我将不得不手动将其添加到代码中。
更新
如果要显示某个集合之后的所有集合,一旦找到该句柄,就让它在找到句柄后解析其余集合。
抱歉,我的液体有点生锈,所以这是伪代码。
{{ liquidtempvar = 0 }}
{% loop through collections %}
{% if thiscollection.handle == 'firstcollectioniwanttodisplay' %}
{{ liquidtempvar = 1 }}
{% endif %}
{% if liquidtempvar eq 1 %}
{{ loop through this collection and every collection after }}
<a href="{{collection.product.url}}">{{ collection.product.handle }}</a>
{{ endloop }}
{% endif %}
{{ endloop }}
类似的东西...
更新结束
如果要将集合中的项目列表显示为链接,则需要在要显示它们的页面模板中解析集合对象。
您可能希望使用集合 handle 来 qualify/filter 您想要显示的集合。
在每个集合上使用液体循环,如果句柄与您想要的集合匹配,则在集合上循环并显示链接。
如果您希望通过导航将其作为菜单来执行此操作,我认为您可以使用 URL.
中的查询字符串来执行此操作
collection.next_product
和
collection.prev_product
将 return 集合中下一个和上一个产品的 URL。
假设我想在 Shopify 的 2 个不同页面上显示 2 个不同的 collection 列表(只是标题及其相关页面的链接); Shopify 中有什么方法可以做到吗?据我所知,我要么在页面上显示所有 "Collections",要么根本显示 none。是否没有选项可以对它们进行分类,以便我可以使用 liquid 仅显示某些 collections?
我发现的唯一其他选择是对页面上的 collection 菜单进行硬编码。但问题是,我创建的任何新 collection,如果我想显示它,我将不得不手动将其添加到代码中。
更新
如果要显示某个集合之后的所有集合,一旦找到该句柄,就让它在找到句柄后解析其余集合。
抱歉,我的液体有点生锈,所以这是伪代码。
{{ liquidtempvar = 0 }}
{% loop through collections %}
{% if thiscollection.handle == 'firstcollectioniwanttodisplay' %}
{{ liquidtempvar = 1 }}
{% endif %}
{% if liquidtempvar eq 1 %}
{{ loop through this collection and every collection after }}
<a href="{{collection.product.url}}">{{ collection.product.handle }}</a>
{{ endloop }}
{% endif %}
{{ endloop }}
类似的东西...
更新结束
如果要将集合中的项目列表显示为链接,则需要在要显示它们的页面模板中解析集合对象。
您可能希望使用集合 handle 来 qualify/filter 您想要显示的集合。
在每个集合上使用液体循环,如果句柄与您想要的集合匹配,则在集合上循环并显示链接。
如果您希望通过导航将其作为菜单来执行此操作,我认为您可以使用 URL.
中的查询字符串来执行此操作collection.next_product
和
collection.prev_product
将 return 集合中下一个和上一个产品的 URL。