process-each
Class:
\CPSIT\
Iterates over an array (or other iterable) and, for each item, evaluates a
variables
configuration block and/or runs a nested
data chain against that single item. This is the
usual way to enrich or reshape every entry of an array produced by an
earlier processor — for example, running
object-
against each file reference returned by TYPO3's core
files
processor.
Resolving the items to iterate
The value to iterate over is resolved in the following order:
data, if configured — see Resolving a data payload (dataSource / data) for how it is resolved, including what happens when multiple references are configured.Source - Otherwise, an inline
dataarray configured directly on this processor. - Otherwise, a
datakey already present inprocessed. This makesData process-usable as a nested processor insideeach iterable-orto- array object-— both of which wrap each item asaccess datafor their own nesteddatachain — without having to repeatProcessing dataexplicitly.Source
If none of these yield an iterable value, the processed data is returned unchanged.
Usage
tt_content.textpic = HANDLEBARSTEMPLATE
tt_content.textpic {
templateName = @textpic
dataProcessing {
10 = files
10 {
references.fieldName = image
as = files
}
20 = process-each
20 {
dataSource = processedData:files
as = processedFiles
dataProcessing {
10 = object-access
10 {
object = contentObjectConfiguration:currentValue
path = publicUrl
as = url
}
20 = object-access
20 {
object = contentObjectConfiguration:currentValue
path = fileType
as = type
}
}
}
}
}
Each file reference resolved by the core
files
processor is
made available to the nested
data chain as
current, reachable as
content (see
Data sources), so
object- can pull
individual properties off it. The per-item results are collected — keyed by
the original array keys — under
processed.
Per-item processing
Two mechanisms are available for each item, and can be combined:
variables-
A
variablesblock, processed exactly like the top-levelvariablesofHANDLEBARSTEMPLATE, but with the content object's current value set to the item. Usecurrent = 1(instead offield) to reference the item itself:20 = process-each 20 { dataSource = processedData:tags as = processedTags variables { label = TEXT label.current = 1 label.case = upper } }Copied!dataandcurrentare reserved and cannot be used as variable names here. dataProcessing - A standard nested
datachain (see Usage), with the item exposed asProcessing current. Its result is merged with — and overrides — whateverValue variablesproduced for the same item.
Properties
data- Inline data to iterate over, used if
datais not configured (see Resolving the items to iterate).Source dataSource - Data source(s) to read the iterable from (see Resolving the items to iterate).
as- Target key in the processed data array the resulting (keyed) array is
stored under. Default:
result. variables- Per-item variables block (see Per-item processing).
dataProcessing - Per-item nested data processors (see Per-item processing).