Feature: #108623 - Allow content element restrictions per colPos
See forge#108623
Description
Backend layouts have been extended with options to allow only
configured types of content elements (referencing
tt_ with names like "text",
"textmedia", "felogin_pi1" and so on) in backend layout columns (
col): The two
keys
allowed and
disallowed add allow and
deny lists on column level. These settings can be set with Page TSConfig based backend layouts,
Database based backend layouts do not allow configuring this value at the moment, but this will
be added soon.
Example for a backend layout with two rows and two columns configured using Page TSConfig:
mod.web_layout.BackendLayouts {
exampleKey {
title = Example
config {
backend_layout {
colCount = 1
rowCount = 2
rows {
1 {
columns {
1 {
identifier = main
name = Main content
colPos = 0
allowedContentTypes = header, textmedia
}
2 {
identifier = right
name = Panel right
colPos = 1
allowedContentTypes = my_custom_cta
}
}
}
2 {
columns {
1 {
identifier footer
name = Footer
colpos = 2
colspan = 2
disallowedContentTypes = header
}
}
}
}
}
}
The implementation adapts the "New content element wizard" to show only allowed (or not disallowed) content elements types when adding a content element to a column. When editing records, the select boxes "Type" and Column position" are reduced to not allow invalid values based on the configuration. Similar logic is applied when moving and copying content elements.
The feature has been created with extension content_defender
in mind. This extension by Nicole Hummel has been around for many years and found huge adoption rates
within the community. In comparison to content_defender, the core configuration is slightly simplified
and the core implementation does not provide the additional content_defender feature to restrict the number
of elements per column (
maxitems).
The core implementation supports the content_defender syntax using the arrays
allowed. and
disallowed.. With the example below,
allowed. is internally mapped to
allowed. When both
allowed. and
allowed
are given,
allowed. is ignored.
mod.web_layout.BackendLayouts {
exampleKey {
config {
backend_layout {
rows {
1 {
columns {
1 {
allowed {
CType = header, textmedia
[...]
Codewise, the PSR-14 event
Manipulate has been added. It allows manipulation
of the calculated column configuration. It is marked
@internal and thus needs to be used with care since it may
change in the future without further note: The event is not dispatched as systematically as it should be, but refactoring
the surrounding code can probably not be provided with TYPO3 v14 anymore. Extensions like ext:container however
must be able to adapt column configuration with TYPO3 v14 already. The decisions was to provide an event, but to mark
it internal for the time being, declaring it as "use at your own risk" if you know what you are doing and within extensions
that set up proper automatic testing to find issues if the core changes internals.
Impact
Backend layout columns can now restrict, which content element types are allowed or disallowed inside of it.