问题描述
如果用户点击一个类名为3-col"的按钮,它将执行以下代码:{% assign products_per_row = "3" %}".
If a user click on a button which has class name: '3-col', it will execute the following code: '{% assign products_per_row = "3" %}'.
如果用户单击4-col"按钮,它将执行以下代码:{% assign products_per_row = "4" %}".
and if a user click on a '4-col' button, it will execute the following code: '{% assign products_per_row = "4" %}'.
但是下面的代码不起作用.
However the code below doesn't work.
我已经研究了所有方法来做到这一点,但我做不到.任何建议表示赞赏.谢谢!
I have researched all ways to do that, but I couldn't. Any advice is appreciated. Thanks!
<button class='3-col' onclick="prod3()"></button>
<button class='4-col'onclick="prod4()" ></button>
{% include 'product-loop' with settings.collection_sidebar %}
<script type="text/javascript">
function prod3(){
{% assign products_per_row = "3" %}
}
function prod4(){
{% assign products_per_row = "4" %}
}
</script>
推荐答案
- 没有办法像你那样做.
- 但我给你相关的提及:
- 参考链接https://full-the-style.myharavan.com/collections/全部;然后单击左侧栏上的过滤项,然后右侧栏必须根据您的选择更改一些项目.
- 在 Chrome 上,您可以按 F12,检查网络选项卡,再次单击左侧栏上的过滤项;确保您可以看到请求/search?...view=grid_and_control";=> 通过向指定的搜索页面模板发送请求来解决您的问题.
- There's no way to do like yours.
- But I give you relevant-mention:
- Refer the link https://full-the-style.myharavan.com/collections/all; then click a filter-item on the left-bar, then right-bar must change some items following your choose.
- On Chrome, you can press F12, check Network tab, click a filter-item on left-bar again; make sure that you can see request "/search?...view=grid_and_control"; => solve your problem by sending request to a specified search-page TEMPLATE.
- 在您的 Shopify 后台/主题中,创建 2 个搜索页面模板:search.3col.liquid"&search.4col.liquid.
- 在每个按钮上,您可以向具有 2 个视图的搜索页面发出请求:/search?view=3col"&/search?view=4col"
- 然后,您可以使用 HTML、CSS 制作任何内容,当然还可以使用上面 2 个搜索页面上的液体代码.
PS:上面的网站基于Haravan.com,它就像Shopify.com(创建您自己的商店,使用液体代码自定义主题......)
PS: The site above based on Haravan.com, it just likes Shopify.com (create your own store, customize theme with liquid code... )
这篇关于shopify 点击不同的按钮会运行不同的液体代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!