Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typo3 流体:if-then-elseif-else_Typo3_Fluid - Fatal编程技术网

Typo3 流体:if-then-elseif-else

Typo3 流体:if-then-elseif-else,typo3,fluid,Typo3,Fluid,我对fluid有点陌生,我想在fluid中创建以下php语句 if ($var == 'something') { // do something } elseif ($other-var == 'something else') { // do something else } else { // do then the other thin } 我如何在液体中制作这个?我在文档中没有看到elseif语句。因为键入3 8LTS 由于第8版TYPO3使用了fluid的独立版本

我对fluid有点陌生,我想在fluid中创建以下php语句

if ($var == 'something') {
   // do something
} elseif ($other-var == 'something else') {
   // do something else
} else {
   // do then the other thin
}
我如何在液体中制作这个?我在文档中没有看到elseif语句。

因为键入3 8LTS 由于第8版TYPO3使用了fluid的独立版本,该版本得到了大量开发,并获得了大量新功能,如
elseif

<f:if condition="{var} == 'something'">
    <f:then>do something</f:then>
    <f:else if="{other-var} == 'something else'">do something else</f:else>
    <f:else>do the other thing</f:else>
</f:if>

做点什么
做点别的
做另一件事
此外,还支持以下语法:

<f:if condition="{something} || {someOtherThing}">
    Something or someOtherThing
</f:if>

某物或某物
直到并包括打字3 7LTS 使用普通流体,如果ViewHelper:

<f:if condition="{var} == 'something'">
    <f:then>
       // do something
    </f:then>
    <f:else>
        <f:if condition="{other-var} == 'something else'">
            <f:then>
                // do something else
            </f:then>
           <f:else>
               // do then the other thing
           </f:else>
        </f:if>
    </f:else>
</f:if>

//做点什么
//做点别的
//然后做另一件事

或者,您可以实现自己的ViewHelper,或者使用像VHS这样的ViewHelper库,该库有一个ViewHelper,可以更优雅地实现这一点。

在Typo3 7 LTS中有AND和Or的可能性:

以及:


或者(在检查至少一个变量是否为空的示例中):



希望这对某人有所帮助。

在TYPO3 8中,确保f:else if=“{other var}”中的{other var}不包含类似“100%foo-0%bar”的计算字符串。这将导致未捕获的TYPO3异常错误“模零”
<f:if condition="{0: value1, 1: value2} == {0: myValue1, 2: myValue2}"> 
    <!-- your code-->
</f:if>
<f:if condition="{0: value1, 1: value2} != {0: 0, 2: 0}"> 
    <!-- your code-->
</f:if>