0

以下打字稿搜索随机子页面并呈现在媒体字段中引用的第一张图像。有用。但是当媒体字段为空时,我需要一个默认图像。

page.10 = COA_INT
page.10 {
  10 = CONTENT
  10 {
    table = pages
    select {
      orderBy = rand()
      max = 1
      pidInList = 34
    }

    renderObj = COA
    renderObj {

      5 = FILES 
      5 {
        references {
          table = pages
          uid.data = current:uid
          fieldName = media
        }
        begin = 0
        maxItems = 1
        renderObj = IMAGE
        renderObj {
          file.import.data = file:current:publicUrl
        }
      }
    }
  }
}

我试过了

file = fileadmin/....
file.import.data = file:current:publicUrl
file.treatIdAsReference = 1

或者

file.import.ifEmpty = fileadmin/....

或覆盖,但当字段媒体中没有文件时,似乎整个 FILES-Object 为空,因此未达到 ifEmpty。

任何人都可以给我一个提示吗?

编辑:TYPO3 6.2

4

1 回答 1

1

pcampe 给了我正确的提示 - 覆盖或ifEmpty必须启动一个级别:

5.stdWrap.ifEmpty.cObject = IMAGE
5.stdWrap.ifEmpty.cObject {
      file = fileadmin/ .....
      file.height = 200c
      file.width  = 200c
}
于 2016-09-15T20:49:59.813 回答