如何根据TypoScript中的SQL检查设置变量?

时间:2011-08-19 20:08:19

标签: typo3 typoscript

我的TypoScript代码中有一个数据库表“tt_content”检查。
根据CONTENT是否为空,我想将变量VAR设置为“空”或“满”。
有可能吗?

MIDCONTENT= CONTENT
MIDCONTENT{
  table = tt_content
  select.orderBy = sorting
  select.where = colPos = 0  
}

我已经找到了一种方法,通过执行

将MIDCONTENT itselfe设置为空
MIDCONTENT= CONTENT
MIDCONTENT{
  table = tt_content
  select.orderBy = sorting
  select.where = colPos = 0  

  stdWrap.ifEmpty.cObject = TEXT
  stdWrap.ifEmpty.cObject.value = empty
}

但我需要的是设置另一个变量,我需要检查完整状态。

2 个答案:

答案 0 :(得分:0)

你需要这样的东西:

enable = 1
enable.if.isTrue.field = MIDCONTENT

我没有安装我的typo3进行测试。另外,你没有真正描述你想做什么...更多细节可以帮助你更多。

答案 1 :(得分:0)

<强>未测试

如果我向右倾斜,只有在该页面中有tt_content记录时,才想向ATagParams添加class =“full”?

NO.ATagParams.append = TEXT
NO.ATagParams.append {
  value = class="full"
  # Space before and after
  noTrimWrap = | | |
  if.isTrue.numRows {
    table = tt_content
    select {
      where = colPos = 0 
      # the uid of the page, is the pid of the tt_content elements
      pidInList.field = uid
    }
  }
}

如果该页面上没有记录,numRows将返回0,因此if.isTrue将返回false并且不会呈现TEXT对象。