我正在尝试制作前进和后退按钮,这些按钮将显示在集合页面的产品页面上。当在集合页面上选择过滤器然后单击产品时,我想制作根据用户选择的过滤器在列出的产品上前进和后退的按钮。我的按钮只能在整个集合页面上前进和后退。如何重写下面的代码以处理根据过滤器列出的产品?
{%- liquid
assign previous_product = collection.previous_product
assign next_product = collection.next_product
assign backFunc =
if previous_product or next_product
else
assign collectionList = product.collections[0].handle
assign previous_product = nil
assign next_product = nil
assign last = collections[collectionList].products_count
for p in collections[collectionList].products
if p.handle == product.handle
assign prev = forloop.index | minus: 2
assign next = forloop.index
if prev >= 0
assign previous_product = collections[collectionList].products[prev].handle
endif
if last >= next
assign next_product = collections[collectionList].products[next].handle
endif
break
endif
endfor
endif
-%}
{%- if previous_product -%}
Prev
{%- endif -%}
{%- if next_product -%}
Next
{%- endif -%}
我在互联网上进行了搜索,但没有找到任何结果。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号