Collections 如何在shopify收藏页面上突出显示自定义标记列表中的活动项
在本支持论坛的帮助下,我已将自定义标记添加到我的收藏页面: 出现在集合页面上的标记由导航中的链接列表定义。我在上面发布的讨论论坛中有更多关于这方面的内容 我插入到collection-template.liquid中的代码片段就在标题下方:Collections 如何在shopify收藏页面上突出显示自定义标记列表中的活动项,collections,tags,filtering,customization,shopify,Collections,Tags,Filtering,Customization,Shopify,在本支持论坛的帮助下,我已将自定义标记添加到我的收藏页面: 出现在集合页面上的标记由导航中的链接列表定义。我在上面发布的讨论论坛中有更多关于这方面的内容 我插入到collection-template.liquid中的代码片段就在标题下方: {% capture collection_taglist %}{{ collection.handle | append: "-tags" }}{% endcapture %} {% if linklists[collection_taglist] %}
{% capture collection_taglist %}{{ collection.handle | append: "-tags" }}{% endcapture %}
{% if linklists[collection_taglist] %}
<ul class="tags tags--collection inline-list">
{% for link in linklists[collection_taglist].links %}
<li>{{ link.title | link_to: link.url }}</li>
{% endfor %}
</ul>
{% endif %}
请参见此处:(您可以使用密码“eaclim”输入)
任何帮助都将不胜感激
非常感谢:)我在各种情况下都会遇到这种情况。在控制台中运行以下命令可概述问题:
jQuery(".tags").find('a').each(function(){ console.log(this.href);});
URL中的主机不是站点的主机
您需要提取路径名以进行比较。有多种方法可以做到这一点,但在Chrome或Firefox中运行以下命令可以得到这个想法。URL不受广泛支持,因此对于生产,您需要使用不同的方法来解析链接URL:
(function(){
var path = location.pathname;
return jQuery(".tags").find('a').filter(function(){
console.log('checking: '+ this.getAttribute('href'));
var href = new URL(this.getAttribute('href'), location.href);
console.log(href.pathname +' vs '+ path);
return href.pathname == path;
});
})();
(function(){
var path = location.pathname;
return jQuery(".tags").find('a').filter(function(){
console.log('checking: '+ this.getAttribute('href'));
var href = new URL(this.getAttribute('href'), location.href);
console.log(href.pathname +' vs '+ path);
return href.pathname == path;
});
})();