process-variables
Class:
\CPSIT\
Processes a
variables
configuration block — exactly like the
top-level
variables
of
HANDLEBARSTEMPLATE
— within
a data processor chain. This is most useful when combined with other processors
such as
database-, allowing per-record variable processing.
Data sources
as
,
merge
and
variables
are read
from this processor's own configuration block
(
processor) only.
table
is also read
from there, but falls back to a same-named key already present in
processed — this is why
table
, once set by an outer
processor (e.g.
database-), can be picked up by a nested
process- without being repeated explicitly. See
Data sources for what these two sources contain.
The
pre and
post hooks
receive the full
Data, so custom
Data implementations have access to all four
sources (see DataSourceAwareProcessor).
Choosing which record to process
By default, the
field
option of a
variables
entry resolves against the current content element's own record. Configure
data (or an inline
data
array) to process
a different record or array instead — see Resolving a data payload (dataSource / data)
for how it is resolved, and Using the content object's current value for
data. If the resolved payload is not an array,
it is ignored and the current record's own field values are used instead.
Standalone usage
tt_content.my_element = HANDLEBARSTEMPLATE
tt_content.my_element {
templateName = MyElement
dataProcessing {
10 = process-variables
10 {
variables {
header = TEXT
header.field = header
teaser = TEXT
teaser.field = bodytext
teaser.parseFunc < lib.parseFunc_RTE
}
}
}
}
Nested inside another processor
dataProcessing {
10 = database-query
10 {
table = tx_myext_domain_model_item
as = items
dataProcessing {
10 = process-variables
10 {
table = tx_myext_domain_model_item
as = item
variables {
title = TEXT
title.field = title
body = TEXT
body.field = bodytext
body.parseFunc < lib.parseFunc_RTE
}
}
}
}
}
Properties
variables- Variables to process. Same syntax as the top-level
variablesinHANDLEBARSTEMPLATE. table- Database table of the record to use as the data source for field lookups. Defaults to the current content element table.
data- Inline data used as the field-lookup source for
variables, ifdatais not configured (see Choosing which record to process).Source dataSource - Data source(s) to use as the field-lookup source for
variables, instead of the current record (see Choosing which record to process). as- Target key in the processed data array. When set, the processed variables are stored under this key. When omitted, the processed variables replace (or merge into) the root of the processed data.
merge- Boolean. When
1andasis omitted, the processed variables are merged into the existing processed data rather than replacing it. Whenasis set and the key already holds an array, the processed variables are merged into that array. Default:0. if- Standard TypoScript
ifcondition. When the condition evaluates to false, the processor is skipped and the processed data is returned unchanged. preProcessing - Data source aware processors run before
variablesare processed. postProcessing - Data source aware processors run after
variablesare processed.