lufi
lufi

Reputation: 670

Add caption to TYPO3 renderObj for slider

I am using this little snippet for a slider:

table = tt_content
select {
    where = colPos = 0
    orderBy = sorting
    languageField = sys_language_uid
}
renderObj =  FILES
renderObj {
    references {
        table = tt_content
        fieldName = image
    }
    renderObj = IMAGE
    renderObj {
        file.import.data = file:current:publicUrl
        stdWrap.typolink.parameter.data = file:current:link
        stdWrap.wrap = <li>|</li>
    }
}

Works great and I like that it's very compact other than much more complex code I found around.

I would now like to add the imagecaption field to display text within a slide, but could not get it work.

Does anyone has a hint on that?

Upvotes: 1

Views: 2052

Answers (2)

Martin
Martin

Reputation: 11

the fieldname just isn't caption, but description: file:current:description

Upvotes: 0

lorenz
lorenz

Reputation: 4558

That depends on where your slider wants to take the caption from. If it can get it from the title or alt tag of your image, you could just add the caption to your renderObj:

renderObj = IMAGE
renderObj {
    file.import.data = file:current:publicUrl
    titleText = file:current:caption
    stdWrap.typolink.parameter.data = file:current:link
    stdWrap.wrap = <li>|</li>
}

or

renderObj = IMAGE
renderObj {
    file.import.data = file:current:publicUrl
    altText = file:current:caption
    stdWrap.typolink.parameter.data = file:current:link
    stdWrap.wrap = <li>|</li>
}

If you need to have it inside an own tag, you should go for the COA approach as suggested by Urs:

renderObj = COA
renderObj {
  10 = IMAGE
  10 {
    file.import.data = file:current:publicUrl
    stdWrap.typolink.parameter.data = file:current:link
  }
  20 = TEXT
  20 {
    data = file:current:caption
    wrap = <span class="imagecaption">|</span>
  }
  wrap = <li>|</li>
}

Upvotes: 2

Related Questions