0
votes

I'm using a fluidtemplate for my website project and want to get a file reference from pages table which I added. But, why isn't it possible to get the file reference unrendered via variables?

//Not working
page.10 = FLUIDTEMPLATE
page.10.variables {
    test = FILES
    test {
        references {
            table = pages
            uid.data = page:uid
            fieldName = tx_myext_myfield
        }
    }
}

//but its working with adding
page.10.variables.test {
    renderObj = IMAGE
    renderObj {
        file.import.dataWrap = {file:current:storage}:{file:current:identifier}
        altText.data = file:current:title
    }
}
1

1 Answers

1
votes

Normal TypoScript objects (like FILES) always return a string. If you want to get the files as a variable in Fluid, you should use a DataProcessor (https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html#dataprocessing). TYPO3 has a default DataProcessor for files, which you can use like this:

page.10 = FLUIDTEMPLATE
page.10.dataProcessing {
  1 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
  1 {
    references.fieldName = tx_myext_myfield
    as = myfiles
  }
}

This will make the files available in Fluid as the variable myfiles