Data sources
Data processors often need to work on data that was prepared earlier, for
example the files returned by TYPO3's
files
processor or an
object assigned by an Extbase controller. The data processors provided by this
extension can read such data from so-called data sources.
Available data sources
| Data source identifier | Contains |
|---|---|
processor | This processor's own config block |
processed | Output of previous processors and variables |
content | Current record's field values |
content |
HANDLEBARSTEMPLATE
configuration,
or the configuration forwarded by a parent
processor |
Referencing data
Processors such as process-each accept a
data option that tells them which data to work on. Some
processors use a more specific option name for the same purpose, e.g.
iterable
(iterable-to-array),
object
(object-access) or
file
(media).
A reference consists of the data source identifier, a colon and the key
within that data source. Nested keys are separated by
/
:
dataProcessing {
10 = files
10 {
references.fieldName = image
as = files
}
# All files
20 = process-each
20 {
dataSource = processedData:files
# ...
}
# The first file only
30 = media
30 {
file = processedData:files/0
as = image
}
}
Instead of referencing existing data, inline data can be configured with
the
data
option:
20 = process-each
20 {
data {
10 = foo
20 = bar
}
}
If a reference cannot be resolved, a warning is logged and the processor leaves the processed data unchanged.
See also
Data source resolution for the complete resolution rules, e.g. how multiple references are merged.
Using the current value
Processors that run nested inside process-each or
iterable-to-array receive the item currently being
processed as the content object's current value. The same applies to
process-variables if its resolved payload is not an
array. Set
current = 1
as sub-property of the data source option to use it. This works for all
processors listed above, e.g.
data,
object. or
iterable.:
20 = process-each
20 {
dataSource = processedData:files
as = processedFiles
dataProcessing {
10 = object-access
10 {
object.current = 1
path = publicUrl
as = url
}
}
}
Alternatively, the item can be referenced as
content.
Wrapped current values
std functions expect the current value to be a string.
Values which cannot be converted to strings, such as arrays or objects, would
therefore break TypoScript such as
current = 1
or
if.. To prevent this, such values are wrapped
in a
\CPSIT\
object before being provided as current value. Scalar values,
null
and
stringable objects (implementing
\Stringable
) are provided as-is.
For wrapped, non-stringable values, the following applies:
- Within
std, arrays resolve to a comma-separated list of their scalar values and stringable objects (e.g.Wrap foo,bar). Nested arrays, non-stringable objects andnullvalues are skipped. All other values resolve to an empty string (so e.g.ifapplies).Empty - The
current = 1sub-property of data source options (e.g.object.) resolves to the original, unwrapped value.current - Custom code reading the current value via
Contentreceives the wrapper and can access the original value via itsObject Renderer:: get Current Val () valueproperty, see Accessing the current value.