我在Typo3 Fluid模板中有一个对象,并且想要访问它的属性,但该属性的名称存储在变量someProperty
中:
<f:if condition="searchObject.{someProperty}">
Found!
</f:if>
由于这种方法无法工作:是否有内置的方法可以通过变量访问属性?
{searchObject.{someProperty}}
{array.{variableContainingKey}}
。点符号实际上是访问属性的正确方式。你所说的动态是什么意思?可以为空吗?你尝试过以下方法吗?
<f:if condition="<f:count>{searchObject.someProperty}</f:count>">
Found!
</f:if>
或者只是:
<f:if condition="{searchObject.someProperty}">
Found!
</f:if>