调用shopify设置时在液态if语句中可变 [英] Variable within liquid if statement when calling shopify settings

查看:92
本文介绍了调用shopify设置时在液态if语句中可变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这将很容易解决,但是我试图将一个变量放入一个流动的语句中.

I thought this would be simple to solve but I am trying to put a variable within a liquid statement.

我有我的变量{{ loop_index }},我希望它位于此语句内:

I have my variable {{ loop_index }} and I want it to be within this statement :

{% if settings.dropdown-[loop_index]-select  %}

我尝试将其绕过,但是没有用.基本上应该说settings.dropdown-1-select,settings.dropdown-2-select.

I tried putting [...] round it but that didn't work. Basically it should say settings.dropdown-1-select, settings.dropdown-2-select.

我在做什么错了?

推荐答案

创建一个包含变量名称的字符串,然后使用

Create a string containing the variable name, then use the square bracket notation to access the setting with that name. For example:

{% capture var %}dropdown-{{ loop_index }}-select{% endcapture %}
{% if settings[var] %}

这篇关于调用shopify设置时在液态if语句中可变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆