Typo3 4.5从tt_content获取图像名称

时间:2013-08-12 14:43:49

标签: typo3 typoscript

我现在卡在我的代码中:/

我想从我的数据库中获取图像名称并对其进行格式化。

这是我的TS代码:

temp.slider = COA
temp.slider{

#slider
200 = TEXT
200.value = <div class="slider">

300 = COA
300.table = tt_content
300.select {
    orderBy = sorting
    where = (colPos = 3 AND CType = "image")
    languageField = sys_language_uid


    renderObj = TEXT
    renderObj {
        field = image
        split {
             token = ,
             cObjNum = 1
             1.cObject = IMG_RESOURCE
             1.cObject {
                 file {
                     import = fileadmin/images/
                     import.current = 1
                 }
                 stdWrap.wrap = <img width="615" height="230" alt="" src="fileadmin/images/|" >
                 stdWrap.insertData = 1
        }
    }
}
}

我需要的输出是:

<img width="615" height="230" alt="" src="fileadmin/images/image1.jpg">
<img width="615" height="230" alt="" src="fileadmin/images/image2.jpg">
<img width="615" height="230" alt="" src="fileadmin/images/image3.jpg">

1 个答案:

答案 0 :(得分:1)

未经测试,我想这应该工作:) 检查图像的位置,我猜fileadmin / images /不正确。您可以在后端打开图像,看看路径是什么。

300 = CONTENT
300.table = tt_content
300.select {
    orderBy = sorting
    where = (colPos = 3 AND CType = "image")
    languageField = sys_language_uid


    renderObj = TEXT
    renderObj {
        field = image
        split {
             token = ,
             cObjNum = 1
             1 {
                10 = IMAGE
                10 {
                   file {
                      import = uploads/pics/
                      import.current = 1
                      # "c" means cropping, so if it is not able to scale that image
                      # it will be cropped to fit 615x230
                      width = 615c
                      height = 230c
                   }
                }
             }
        }
    }
}

出于调试目的,您可以检查输出的内容:

检查内容是否有一些内容:

renderObj = TEXT
renderObj {
  field = image
}

检查拆分是否有效:

renderObj = TEXT
renderObj {
  field = image
  split  {
    token = ,
    cObjNum = 1
    1 {
      10 = TEXT
      10.current = 1
      10.wrap = <span>This is the image filename: |</span><br />
    }
  }
}