【问题标题】:TYPO3: Condition "if column empty"?TYPO3:条件“如果列为空”?
【发布时间】:2016-02-26 11:15:56
【问题描述】:

我正在寻找一个条件来检查某个列是否为空。

类似这样的:

[colPos.0 = empty]
#do stuff
[global]

提前致谢。

编辑:
我认为目前还不清楚我在寻找什么。所以让我补充一些信息:

我在 BE (colPos = 0) 中有一个预告图片列。如果它包含一个元素,它应该定期显示这个元素。如果不是(== 如果为空),它应该使用另一个图像。

【问题讨论】:

  • 您使用哪个版本的 TYPO3 以及哪个模板引擎? IE。如果你使用流体 - 你可以只使用 f:if 条件,否则检查这个 sn-p:typo3.org/documentation/snippets/sd/110
  • @biesior 好吧,我不知道如何使用您的 sn-p,但它给了我另一个导致解决方案的想法。刚刚将<f:if condition="{col0}"> 添加到我的流体模板中。非常感谢!

标签: typo3 conditional-statements typoscript


【解决方案1】:

当然有可能显示一个列是否有内容的东西, 但没有 TS 条件。

基于https://kuttler.eu/en/post/change-template-if-content-exists-in-typo3/,
这是我的解决方案:

temp.foo {
temp.foo = COA

    10 = COA
    10 {
        10 < styles.content.get
        10.select.where = colPos=1

        # conditional to test if content exists in column
        if.isTrue.numRows {
            # check current page page
            pidInList = this
            # in the table tt_content
            table = tt_content
            # colPos = 1
            select.where = colPos=1
        }
    }

    20 = COA
    20 {
        10 < lib.somethingElse

        # conditional to test if content exists in column
        if.isFalse.numRows {
            # check current page page
            pidInList = this
            # in the table tt_content
            table = tt_content
            # colPos = 1
            select.where = colPos=1
        }
    }
} 

if.isTrueif.isFalse 正在这里发挥作用。

HTH

【讨论】:

    【解决方案2】:

    您可以使用if function,示例(来自文档):

    page.10 = COA_INT
    page.10.10 = TEXT
    page.10.10 {
      stdWrap.if.isNull.field = description
      value = No description available.
    }
    

    编辑:另外,如果你使用流体模板,你可以只使用f:if 条件。

    【讨论】:

    • 感谢您的快速回复。但我正在尝试检查列的内容,是否填充了内容元素。给我一分钟,我将编辑问题以获得更多许可。
    猜你喜欢
    • 2015-09-28
    • 1970-01-01
    • 2013-05-08
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    • 2014-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多