FilesProcessor¶
This data processor can be used for processing file information:
- relations to file records (sys_file_reference)
- fetch files records by their uids in table (sys_file)
- all files from a certain folder
- all files from a collection
A FLUIDTEMPLATE
can then simply iterate over processed data automatically.
Options:¶
-
if
¶ Required: false Type: if condition Default: ’’ If the condition is not met the data is not processed
-
references
¶ Required: false Type: string (comma separated integers), stdWrap Default: ‘’ ‘1,303,42’ If this option contains a comma separated list of integers these are treated as uids of file references (sys_file_reference).
The corresponding file records are added to the output array.
New in version 10.3: stdWrap properties got added to the references property .
-
references.fieldName
¶ Required: false Type: string, stdWrap Default: ’’ Example: ‘media’ If both
references.fieldName
andreferences.table
are set the file records are fetched from the referenced table and field, for example themedia
field of att_content
record.
-
references.table
¶ Required: false Type: string, stdWrap Default: ’’ Example: ‘tt_content’ If
references
should be interpreted as TypoScript select function, references.fieldName must be set to the desired field’s name of the table to be queried.
-
files
¶ Required: false Type: string (comma separated integers), stdWrap Default: ’’ Example: ‘1,303,42’ If this option contains a comma separated list of integers, these are treated as uids of files (sys_files).
-
collections
¶ Required: false Type: string (comma separated integers), stdWrap Default: ’’ Example: ‘1,303,42’ If this option contains a comma separated list of integers, these are treated as uids of collections. The file records in each collection are then being added to the the output array.
-
folders
¶ Required: false Type: string (comma separated folders), stdWrap Default: ”” Example: “23:/other/folder/” Fetches all files from the referenced folders. The following syntax is possible:
t3://folder?storage=2&identifier=/my/folder/
folder “/my/folder/” from storage with uid 223:/other/folder/
folder “/other/folder/” from storage with uid 23/folderInMyFileadmin/something/
folder “/folderInMyFileadmin/something/” from the default storage 0 (fileadmin)
-
folders.recursive
¶ Required: false Type: string, stdWrap Default: ”” Example: “1” If set to a non-empty value file records will be added from folders recursively.
-
sorting
¶ Required: false Type: string, stdWrap Default: ”” Example: “filesize” The property of the file records by which they should be sorted. For example filesize or title.
-
sorting.direction
¶ Required: false Type: string, stdWrap Default: “ascending” Example: “descending” The sorting direction (‘ascending’ or ‘descending’)
-
as
¶ Required: false Type: string, stdWrap Default: “files” The variable’s name to be used in the Fluid template
-
dataProcessing
¶ Required: false Type: array of dataProcessing Default: ”” Array of DataProcessors to be applied to all fetched records.
Example 1: Render the images stored in field image¶
Please see also About the examples.
TypoScript¶
Using the FilesProcessor
the following scenario is possible:
tt_content {
examples_dataprocfiles =< lib.contentElement
examples_dataprocfiles {
templateName = DataProcFiles
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
dataProcessing.10 {
as = images
references.fieldName = image
references.table = tt_content
sorting = title
sorting.direction = descending
}
}
}
The Fluid template¶
In the Fluid template then iterate over the files:
<html data-namespace-typo3-fluid="true" xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
<h2>Data in variable images</h2>
<f:debug inline="true">{images}</f:debug>
<h2>Data in variable images</h2>
<div class="row">
<div class="row">
<f:for each="{images}" as="image">
<div class="col-12 col-md-3">
<div class="card">
<f:image image="{image}" class="card-img-top" height="250"/>
<div class="card-body">
<h5 class="card-title">{image.title}</h5>
<div class="card-text">{image.description}</div>
</div>
</div>
</div>
</f:for>
</div>
</div>
</html>
Output¶
The array images
contains the data of the files now.

Note
For technical reasons FileReferences do not show all available data on using debug. See Using FAL in the Frontend.
Example 2: use stdWrap property on references¶
New in version 10.3: stdWrap properties added to the FilesProcessor
.
The following example implements a slide-functionality on rootline for file resources:
page.10.dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.data = levelmedia: -1, slide
as = myfiles
}
}
The FilesProcessor
can slide up the rootline to collect
images for FLUID templates. One usual feature is to take images
attached to pages and use them on the page tree as
header images in the frontend.