流体:如果 - 那么 - elseif - else
Fluid: if - then - elseif - else
我对 Fluid 有点陌生,我想在 Fluid 中做以下 php 声明。
if ($var == 'something') {
// do something
} elseif ($other-var == 'something else') {
// do something else
} else {
// do then the other thin
}
如何在 Fluid 中制作这个?我在文档中没有看到 elseif 语句。
自 TYPO3 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>
直到并包括 TYPO3 7LTS
如果 ViewHelper:
,您可以使用 Plain Fluid 嵌套两个
<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:
http://typo3blogger.de/fluid-ifviewhelper-conditions-verknupfen/
并且:
<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>
希望对某人有所帮助。
'else if'是否有内联符号?
这个不工作:
{f:if(condition: '{value} == 1', then: 'Value is 1', else if: '{value} == 2', then:'Value is 2')}
我对 Fluid 有点陌生,我想在 Fluid 中做以下 php 声明。
if ($var == 'something') {
// do something
} elseif ($other-var == 'something else') {
// do something else
} else {
// do then the other thin
}
如何在 Fluid 中制作这个?我在文档中没有看到 elseif 语句。
自 TYPO3 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>
直到并包括 TYPO3 7LTS
如果 ViewHelper:
,您可以使用 Plain Fluid 嵌套两个<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:
http://typo3blogger.de/fluid-ifviewhelper-conditions-verknupfen/
并且:
<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>
希望对某人有所帮助。
'else if'是否有内联符号? 这个不工作:
{f:if(condition: '{value} == 1', then: 'Value is 1', else if: '{value} == 2', then:'Value is 2')}