gpt4 book ai didi

typo3 - 流体:if - then - elseif - else

转载 作者:行者123 更新时间:2023-12-03 15:11:03 28 4
gpt4 key购买 nike

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

if ($var == 'something') {
// do something
} elseif ($other-var == 'something else') {
// do something else
} else {
// do then the other thin
}

我怎样才能在流体中做到这一点?我在文档中没有看到 elseif 语句。

最佳答案

自 TYPO3 8LTS

由于第 8 版 TYPO3 使用独立版本的流体,因此经过大量开发并获得了大量新功能,例如 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 可以嵌套两个:
<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 或使用 ViewHelper 库(如 VHS),该库具有更优雅的 ViewHelper。

关于typo3 - 流体:if - then - elseif - else,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29461381/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com