Backend relation scoping
What the scoping does for editors is described in Backend relation scoping. This page covers how it is wired and what to decide when a record kind is added.
To achieve a seamless integration, TCA and Flexform are manipulated after being compiled and the result is then cached. PSR-14 events take care of the manipulation. The final result can be inspected via the Sites -> Page TSconfig and Configuration -> TCA backend modules.
The criterion
\Werkraum decides which fields are scoped and what
clause they carry. A column matches when it is a
select
field, its
foreign_ is
listed in
Site, and it is not the table's translation parent
(ctrl.).
A matching column receives two conditions on the foreign table:
AND {#<foreign_table>}.{#pid} IN (###PAGE_TSCONFIG_IDLIST###)
AND {#<foreign_table>}.{#sys_language_uid} IN (0, -1)
Each condition is appended to the column's existing
foreign_ only when that clause
does not already state it, compared with whitespace removed. Whatever else the clause holds stays
untouched.
Event listeners
Three PSR-14 listeners apply the criterion. Each one derives the fields from it rather than from a list, so the fields carrying the clause and the fields receiving an id list cannot drift apart.
SiteonScoped Relations Tca Listener AfterTca Compilation Event - Writes the clause into every matching column of every table in the compiled TCA.
SiteonScoped Relations Flex Form Listener AfterFlex Form Data Structure Parsed Event - Writes the clause into matching fields of each parsed FlexForm sheet, so a content element
selecting ThueCat records is scoped too. A sheet has no
ctrl, so no field there is excluded as a translation parent. SiteonScoped Relations Page Ts Config Listener ModifyLoaded Page Ts Config Event -
Supplies the value of
###PAGE_. Core resolves the marker per table and field and offers no wildcard, so the listener emits one line per scoped field:TSCONFIG_ IDLIST### TCEFORM.<table>.<field>.PAGE_TSCONFIG_IDLIST = <ids> TCEFORM.<table>.<flexField>.<recordType>.<sheet>.<field>.PAGE_TSCONFIG_IDLIST = <ids>Copied!FlexForm field names containing a dot, such as
settings., are escaped, because TSconfig reads the dot as a path separator. The FlexForm data structure is parsed per record type; a type whose structure cannot be resolved contributes no lines.towns The ids are the pages of the site holding the current page, the deepest entry of the rootline, resolved by
\Werkraum— the service the import uses for the same question. A page outside any site yieldsMedia\ Thue Cat\ Service\ Site Page Ids 0: an unresolved marker would leave the clause offering the whole table.
The type-ahead wizard is limited by
TCEFORM. in
Configuration/page.tsconfig, reading the same marker. Its columns are unqualified, because
the wizard queries one table at a time, while the dropdown's query joins and needs the table name.
Core's
Suggest ignores a field's
foreign_ while TSconfig
sets an add. The language condition is therefore part of the TSconfig block as well: fields
carrying it only in their own
foreign_ would lose it on the wizard while keeping
it on the dropdown.
Category and keyword fields are not part of this mechanism. Their tree start is resolved by the form
data provider
\Werkraum from the
###THUECAT_ marker, see Category and keyword trees.
Adding a record kind
SCOPED_ is the statement of what counts as a ThueCat record, and it is maintained by
hand.
When a new record kind is introduced, decide whether its table belongs in that list. Nothing detects the omission: a relation field pointing at a table missing from it keeps working and offers the records of the whole installation, in every site, on both the dropdown and the suggest wizard.
Adding the table is the usual answer, but not automatic. A table deliberately shared across sites, or one never used as a relation target, is correctly left out.
Append
\Werkraum with the new
table, this is all it takes.