如何在shopify中创建自定义链接?
此链接指向产品类别{{ product_type \ link_to_type }}
代码如下所示
{% for product_type in collection.all_types %}
{{ product_type | link_to_type }}
我想在这个链接旁边添加一个“查看更多”链接,指向同一个链接。这有可能吗?
我试过了但它们不起作用。
{{ '(view more)' | link_to_product_type }}
{{ '(view more)' | link_to_type }}
{{ '(view more)' | link_to: types?q=product_type }}
{{ '(view more)' | link_to: 'types?q='product_type }}
{{ '(view more)' | link_to: types?q=type }}
任何帮助都是非常感谢的。
发布于 2015-10-15 15:54:46
这可以通过在replace
(或replace_first
)过滤器上链接来实现。
{% for product_type in collection.all_types %}
{{ product_type | link_to_type | replace_first: '</a>', ' (view more)</a>' }}
{% endfor %}
这将产生一些类似以下内容的内容:
<a href="/collections/types?q=Type1" title="Type1">Type1 (view more)</a>
<a href="/collections/types?q=Type2" title="Type2">Type2 (view more)</a>
您可以将替换/替换_first的(view more)
部分更改为您想要的任何内容,但是要确保它以</a>
结尾,以关闭标记,并保留标记之前的空间,这样它就不会以Type1(view more)
的形式出现。
https://stackoverflow.com/questions/33149912
复制相似问题