typoscript中的TYPO3常量和条件

时间:2018-03-23 07:12:57

标签: typo3 constants typo3-8.7.x

我有constants.ts文件,其中定义了所有常量。还有一个简单的布尔复选框:

plugin.mycustompage {
  top_header {
    # cat=mycustompage.top_header/privateNumberShow/010; type=boolean; label=Private - show phone number: boolean true or false
    privateNumberShow = 1
    # cat=mycustompage.top_header/privatePhoneNumber/010; type=string; label=Private - phone number
    privatePhoneNumber = 11223344
  }
}

除此之外,lib/contactinfo.ts文件中有一个简单文件,我希望根据TEXT常量值显示/隐藏一些privateNumberShow。如果未选中该复选框,则清除该值,否则显示该值。这是当前的代码:

[globalVar = LIT:0 = {$plugin.mycustompage.top_header.privateNumberShow}]
  lib.contactInfo.20 >
[END]

这不起作用。还尝试了那个也不起作用的那个:

[$plugin.mycustompage.top_header.privateNumberShow = 0]
  lib.contactInfo.20 >
[END]

使用TYPO3 8.7.12。有什么想法吗?

1 个答案:

答案 0 :(得分:3)

转换您的情况并要求LIT:1。这样,当你的常量不是1时,TypoScript解析器不需要解析你的contactInfo,这将有利于你的表现。

[globalVar = LIT:1 = {$plugin.mycustompage.top_header.privateNumberShow}]
lib.contactInfo.20 = TEXT
lib.contactInfo.20{
    value = 123456789
}
[global]