简体   繁体   English

在 TypoScript 中,如果满足 c1&c2&c3 条件,如何在菜单项旁边显示“新建”?

[英]In TypoScript, how to display a 'New' beside a menu item if c1&c2&c3 conditions are fulfilled?

Here is the code in typo3 7.6.27:这是typo3 7.6.27中的代码:

2.NO {
    after = &nbsp;<span class="nouveau">New</span>
    after.if.value.data = date:U
    after.if.isGreaterThan.data = field:f1
    after.if.value.data = field:f2
    after.if.isGreaterThan.data = field:f1
    after.if.value.data = date:U
    after.if.isGreaterThan.data = field:f2
}

You can't add multiple conditions into one if function in typoscript.您不能将多个条件添加到一个if函数中。
Remember: typoscript will be transfered into a php array before it is being evaluated.请记住:typoscript 在被评估之前将被转移到一个 php 数组中。

In your example your second condition overwrite the first, and the third overwrites any before.在你的例子中,你的第二个条件覆盖了第一个,第三个覆盖了之前的任何一个。

Typoscript has no build in mechanism for logical operators, so you need workarounds like userfunc or cascaded stdWrap Typoscript 没有用于逻辑运算符的内置机制,因此您需要解决方法,例如userfunc或级联stdWrap

So a possible solution might be:所以一个可能的解决方案可能是:

2.NO {
    after = &nbsp;<span class="nouveau">New</span>
    after.if.value.data = date:U
    after.if.isGreaterThan.data = field:f1
    after.stdWrap.if.value.data = field:f2
    after.stdWrap.if.isGreaterThan.data = field:f1
    after.stdWrap.stdWrap.if.value.data = date:U
    after.stdWrap.stdWrap.if.isGreaterThan.data = field:f2
}

or you use menuprocessors and fluid after you update to a current version of TYPO3, which is very outstanding if you still use TYPO3 7.6.27 which is out of support for two years.或者您在更新到当前版本的 TYPO3 后使用菜单处理器和流体,如果您仍然使用已停止支持两年的 TYPO3 7.6.27,这将非常出色。 (7.6 ELTS is 7.6.40) (7.6 ELTS 是 7.6.40)


In addition to that, if I want to do a else with a similar block of conditions to display "Updated" if it has been updated, is it possible?除此之外,如果我想用类似的条件块执行 else 以显示“已更新”(如果已更新),是否可能?

There is no else in typoscript condition function.排版条件功能中没有else
you could use override or ifempty but in this case I would suggest to use a COA in the after :您可以使用overrideifempty但在这种情况下,我建议在after使用COA

2.NO {
   after.cObject = COA
   after.cObject {
       10 = TEXT
       10.value = &nbsp;<span class="nouveau">New</span>
       10 {
           if.value.data = date:U
           if.isGreaterThan.data = field:f1
           stdWrap {
               if.value.data = field:f2
               if.isGreaterThan.data = field:f1
               stdWrap {
                   if.value.data = date:U
                   if.isGreaterThan.data = field:f2
               }
           }
       }
       20 = TEXT
       20.value = &nbsp;<span class="update">Updated</span>
       20 {
           if.value.data = date:U
           if.is???Than.data = field:f1
           stdWrap {
               if.value.data = field:f2
               if.isG???Than.data = field:f1
               stdWrap {
                   if.value.data = date:U
                   if.isG???Than.data = field:f2
               }
           }
       }
    }
}

with appropriate conditions for 20 .以适当的条件为20 .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM