0

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

我想从我的数据库中获取图像名称并格式化它们。

这是我的 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">
4

1 回答 1

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
                   }
                }
             }
        }
    }
}

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

检查 CONTENT 是否获得一些内容:

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 />
    }
  }
}
于 2013-08-12T15:53:48.970 回答