TYPO3 内联 if 条件中的流体动态变量部分
TYPO3 Fluid dynamic variable part in inline if condition
我想检查设置中是否存在配置数组,如果存在,将其作为参数传递给部分。如果不存在,将默认配置传递给该部分。
我的问题是,我被困在 if-condition 中,需要执行检查(then-else 在下面进行了简化):
{f:if(condition: settings.media.responsive{f:count(subject: records)}, then: 'true', else: 'false')}
这样的代码不会被Fluid解析,只是直接在页面上输出。
但是,如果没有动态部分,它可以完美运行:
{f:if(condition: settings.media.responsive1, then: 'true', else: 'false')}
输出 true
.
我已经尝试了所有可能的组合:用单引号 and/or 大括号括起整个条件,以及 f:count(subject)
内的相同,但没有找到方法它有效。
另外尝试 v:variable.get
来自 VHS 扩展,但也没有成功:
{f:if(condition: {v:variable.get(name: 'settings.media.responsive{f:count(subject: records)}')}, then: 'true', else: 'false')}
上面的代码总是导致 true
。
重要 注意:settings.media.responsive[number]
包含设置数组,因此不能通过在 condition
中用单引号括起来将其转换为字符串。
如果您使用的是流体引擎库:
{records -> f:variable(name: 'count')}
{f:if(condition: '{f:count(subject: \'{settings.media.responsive{count}}\')}', then: 'true', else: 'false')}
或者如果你想要 VHS:
{f:if(condition: '{v:variable.get(name: \'settings.media.responsive{f:count(subject: records)}\') -> f:count()}', then: 'true', else: 'false')}
我想检查设置中是否存在配置数组,如果存在,将其作为参数传递给部分。如果不存在,将默认配置传递给该部分。
我的问题是,我被困在 if-condition 中,需要执行检查(then-else 在下面进行了简化):
{f:if(condition: settings.media.responsive{f:count(subject: records)}, then: 'true', else: 'false')}
这样的代码不会被Fluid解析,只是直接在页面上输出。 但是,如果没有动态部分,它可以完美运行:
{f:if(condition: settings.media.responsive1, then: 'true', else: 'false')}
输出 true
.
我已经尝试了所有可能的组合:用单引号 and/or 大括号括起整个条件,以及 f:count(subject)
内的相同,但没有找到方法它有效。
另外尝试 v:variable.get
来自 VHS 扩展,但也没有成功:
{f:if(condition: {v:variable.get(name: 'settings.media.responsive{f:count(subject: records)}')}, then: 'true', else: 'false')}
上面的代码总是导致 true
。
重要 注意:settings.media.responsive[number]
包含设置数组,因此不能通过在 condition
中用单引号括起来将其转换为字符串。
如果您使用的是流体引擎库:
{records -> f:variable(name: 'count')}
{f:if(condition: '{f:count(subject: \'{settings.media.responsive{count}}\')}', then: 'true', else: 'false')}
或者如果你想要 VHS:
{f:if(condition: '{v:variable.get(name: \'settings.media.responsive{f:count(subject: records)}\') -> f:count()}', then: 'true', else: 'false')}