Data processors
Common behaviour
Identifiers — every processor is registered under a short identifier, used throughout this documentation and in the shipped TypoScript; the class name works as well:
| Identifier | Processor |
|---|---|
headless- | Database |
headless- | Extract |
headless- | Files |
headless- | Flex |
headless- | Gallery |
headless- | Language |
headless- | Menu |
headless- | Root |
All of them live in the namespace
\Friends.
appendData — the menu, language-menu, gallery and files
processors share a destructive default: with append absent or
0 the processor removes data from the processed result and
strips data from every item in the target (as) array — for menus
recursively through all children. Set append to keep the
raw record data.
Default target names — when as is omitted, each processor falls back
to its default target name:
| Processor | Default as |
|---|---|
| MenuProcessor | menu |
| LanguageMenuProcessor | languagemenu |
| GalleryProcessor | gallery |
| FilesProcessor | media |
| DatabaseQueryProcessor | records |
| RootSitesProcessor | sites |
DatabaseQueryProcessor
The EXT: equivalent of the core DatabaseQueryProcessor.
10 = headless-database-query
10 {
table = tt_content
pidInList = 123
as = contents
fields {
header = TEXT
header {
field = header
}
bodytext = TEXT
bodytext {
field = bodytext
parseFunc =< lib.parseFunc_RTE
}
}
}
Besides if, table, as and nested data, it accepts the
core select properties (pid, recursive, uid,
where, join, order, max, begin, …) directly on the
processor, plus:
fields— JSON-style field map applied to every rowoverride— same, merged over already-processed rowsFields return(Default: 0) — return the single row directly instead of an arrayFlatten Object
fields and override are rendered through the
JSON cObject, so every per-field option
documented there (intval, if, nested fields,
data, …) works inside them.
Warning
Without fields the full raw database row is serialised — every
column of the table. For tables such as fe_ that exposes
password hashes and personal data. Always set fields and list only
the values the frontend needs.
ExtractPropertyProcessor
Extracts a single, possibly nested, property from the processed data.
Both as and key are required — the processor throws an
exception when either is missing. Its result replaces the entire
processed data: only [as => value] survives, everything else the
previous processors produced is discarded.
See the FilesProcessor example below.
FilesProcessor
page.10.fields.ogImageUrl = TEXT
page.10.fields.ogImageUrl {
dataProcessing {
# Use the column 'og_image' to render an array with all relevant
# information (such as the publicUrl)
10 = headless-files
10.as = media
10.references.fieldName = og_image
10.processingConfiguration.returnFlattenObject = 1
# Extract only property 'publicUrl' from the above created array,
# so the field holds the URL string
20 = headless-extract-property
20.key = media.publicUrl
20.as = media
}
}
File sources, as in the core processor; all are stdWrap-enabled and can be combined:
references— comma list ofsys_uids.file_ reference references.— fetch the file references of this relation field of the current record;field Name references.sets the record's table (default: the current table).table files—sys_uids.file collections— file collection uids.folders— combined-identifier folder paths;folders.descends into subfolders.recursive = 1
Further options: sorting (file property, sorting.),
append (see Common behaviour) and the processing
block described in Image rendering.
FlexFormProcessor
Processes a FlexForm field such as tt_ and optionally
overrides values in it.
field defaults to pi_. When as is omitted, the
processed flexform is written back in place — into
data.<field, or the top-level <field key when the value
lives there.
10 = headless-flex-form
10 {
fieldName = pi_flexform
as = flexform
overrideFields {
fieldA = TEXT
fieldA {
value = 123
}
}
}
GalleryProcessor
RootSitesProcessor
10 = headless-root-sites
10 {
as = sites
allowedSites = 1,2,3
sortingField = sorting
}
Lists the root pages of all sites whose site configuration has
headless enabled. All options are optional; all except as are read as
plain values (no stdWrap):
| Option | Meaning |
|---|---|
site | Class implementing
\Friends
that discovers the sites. Default: Site. |
site | Class implementing
\Friends
that shapes each entry. Default: Site. |
sorting | pages column to sort the sites by. Default:
sorting. Must be listed in db. |
sorting | Class implementing
\Friends.
Default: sort by sorting. |
allowed | Comma list of root page uids to list, e.g. to hide sites that are not ready yet. |
sites | Page (or separator) whose subpages are the site
roots; only sites found there are listed. Replaces
allowed when set. Useful for multi-site
instances. |
db | pages columns loaded for each root page and
handed to the schema. Default: uid,title,sorting. |
title | pages column used as the site title. Default:
title. Must be listed in db.
db is read by the default
Site, title by the default
Site; Domain ignores both. |
data | Further data processors, run per entry with the
entry itself as data. They cannot reach the Site
object — put site-derived fields into the schema
class. |
headless_ (?type=835) is built with this processor and
Domain; an example schema extension is in
Multiple sites and ?type=835.