如何在 shopify 中创建自定义 link
how to create custom link in shopify
如何在 shopify 中创建自定义 link?
此 link 到产品类别 {{ product_type | link_to_type}}
代码如下所示
{% for product_type in collection.all_types %}
{{ product_type | link_to_type }}
我想在这个指向同一个 link 的 link 旁边添加一个 "view more" link。这可能吗?
我试过了,但它们不起作用。
{{ '(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 }}
感谢任何帮助
这可以通过链接 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>
您可以将 replace/replace_first 的 (view more)
部分更改为您想要的任何内容,但请确保它以 </a>
结尾以关闭标签并保留 space在它之前所以它不会以 Type1(view more)
.
的形式出现
如何在 shopify 中创建自定义 link?
此 link 到产品类别 {{ product_type | link_to_type}}
代码如下所示
{% for product_type in collection.all_types %}
{{ product_type | link_to_type }}
我想在这个指向同一个 link 的 link 旁边添加一个 "view more" link。这可能吗?
我试过了,但它们不起作用。
{{ '(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 }}
感谢任何帮助
这可以通过链接 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>
您可以将 replace/replace_first 的 (view more)
部分更改为您想要的任何内容,但请确保它以 </a>
结尾以关闭标签并保留 space在它之前所以它不会以 Type1(view more)
.