打字稿每个第4个元素添加一个div

时间:2019-05-19 15:57:00

标签: typo3 typoscript typo3-8.x

我有下面的印刷脚本,可以将元素打印到我的页面中。

lib.unterseiten = CONTENT
lib.unterseiten {
  table = pages
  select {
    pidInList.field = 10
    orderBy = sorting
  }
  renderObj = COA
  renderObj.wrap = <div class='col-md-3'>|</div>
  renderObj {
    10 = TEXT
    10.field = title
    10.wrap = <h2>|</h2>
    20 = CONTENT
    20 {
      table = tt_content
      select {
        pidInList.field = uid
        orderBy = sorting
      }
      renderObj = COA
      renderObj {

        #Bild auslesen
        30 = FILES
        30 {
          maxItems = 1
          references {
            table = tt_content
            uid.data = field:uid
            fieldName = image
            maxItems = 1
         }

         renderObj = IMAGE
         renderObj.file.import.data = file:current:uid
         renderObj.file.treatIdAsReference = 1
         renderObj.wrap = <div class="thumbnail bild">|</div>
          renderObj.stdWrap.maxItems = 1
      }
        40 = TEXT
        40.value = Mehr Infos
        40.typolink.ATagParams = class="btn btn-primary"
        40.typolink.parameter.data  = field:pid
      }
    }

  }
}

page.20.marks.kumulierterInhalt  < lib.unterseiten

是否可以在每个第4个元素之后添加一个div?

谢谢。

更新

lib.unterseiten = CONTENT
lib.unterseiten {
  table = pages
  select {
    pidInList.field = 10
    orderBy = sorting
  }
  renderObj = COA
  renderObj.wrap = <div class='col-md-3'>|</div>
  renderObj {
    10 = TEXT
    10.field = title
    10.wrap = <h2>|</h2>
    20 = CONTENT
    20 {
      table = tt_content
      select {
        pidInList.field = uid
        orderBy = sorting
      }
      renderObj = COA
      renderObj {

        #Bild auslesen
        30 = FILES
        30 {
          maxItems = 1
          references {
            table = tt_content
            uid.data = field:uid
            fieldName = image
            maxItems = 1
         }

         renderObj = IMAGE
         renderObj.file.import.data = file:current:uid
         renderObj.file.treatIdAsReference = 1
         renderObj.wrap = <div class="thumbnail bild">|</div>
          renderObj.stdWrap.maxItems = 1
      }
        40 = TEXT
        40.value = Mehr Infos
        40.typolink.ATagParams = class="btn btn-primary"
        40.typolink.parameter.data  = field:pid
      }
    }
     99 = TEXT
     99.value = ###SEPARATOR###
  }


   stdWrap {
        split {
            token = ###SEPARATOR###
            cObjNum = |*| 1 || 1 || 1 || 2 |*|

            1.current = 1

            2.current = 1
            2.wrap = | <br><br><hr class="separatorline" />
        }
    }

}

page.20.marks.kumulierterInhalt  < lib.unterseiten

1 个答案:

答案 0 :(得分:1)

通常在印刷文字中用adress完成对数组的迭代包装。
包装每个第4个元素将是:

optionsplit

但是尝试使用|*| || || || |<div>...</div> |*| 会导致第一次包装的重复,因为每个renderObj都有自己的上下文,重新开始renderObj

一种解决方法是:
用特殊的模式包装每个元素,例如:optionsplit并分割结果字符串以再次包装。

###SEPARATOR###