92260[FEATURE] Add content element restrictions per colPos
Commit message
Review
-
Code review CR +2 Done
- Stefan Bürk +2
- Garvin Hicking +1
-
Verified V +2 Done
- Stefan Bürk +2
- Garvin Hicking +1
- core-ci +1 CI
Issues 1
Files 17
- typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php10+56 −29
- typo3/sysext/backend/Classes/Controller/Wizard/LocalizationController.php+3 −10
- typo3/sysext/backend/Classes/Form/FieldInformation/BackendLayoutFromParentPage.php+4 −8
- typo3/sysext/backend/Classes/Form/FormDataProvider/TcaTtContentColPosItemsRestrictionByBackendLayout.phpnew+99 −0
- typo3/sysext/backend/Classes/Form/FormDataProvider/TcaTtContentCtypeItemsRestrictionByBackendLayout.phpnew+97 −0
- typo3/sysext/backend/Classes/Hooks/DataHandlerContentElementRestrictionHook.phpnew+126 −0
- typo3/sysext/backend/Classes/Tree/View/AbstractContentPagePositionMap.php2+0 −4
- typo3/sysext/backend/Classes/View/Event/ManipulateBackendLayoutColPosConfigurationForPageEvent.phpnew+44 −0
- typo3/sysext/backend/Classes/View/BackendLayoutView.php4+171 −124
- typo3/sysext/backend/Tests/Functional/Controller/ContentElement/NewContentElementControllerTest.php+11 −30
- typo3/sysext/backend/Tests/Functional/View/BackendLayoutViewTest.php+17 −18
- typo3/sysext/backend/Tests/Unit/View/BackendLayout/BackendLayoutTest.phpdeleted+0 −61
- typo3/sysext/backend/ext_localconf.php+6 −0
- typo3/sysext/core/Configuration/DefaultConfiguration.php+11 −1
- typo3/sysext/core/Documentation/Changelog/14.1/Feature-108623-AllowContentElementRestrictionsPerColPos.rst13new+109 −0
- typo3/sysext/info/Classes/Controller/PageInformationController.php+2 −3
- typo3/sysext/info/Classes/Controller/TranslationStatusController.php+1 −0
Review log 6377
Show 4352 earlier messages
-
Christian Kuhn uploaded patch set 1 01/07/26, 15:09
-
Christian Kuhn uploaded patch set 2 01/08/26, 13:07
-
Christian Kuhn uploaded patch set 3 01/08/26, 13:25
-
Christian Kuhn uploaded patch set 4 01/10/26, 11:17
-
Christian Kuhn uploaded patch set 5 01/11/26, 14:13
-
Christian Kuhn commented on patch set 5 01/11/26, 14:18
-
Christian Kuhn commented on patch set 5 01/11/26, 14:19
NewContentElementController.php:252ReplyDone -
Christian Kuhn uploaded patch set 6 01/11/26, 14:20
-
Christian Kuhn uploaded patch set 7 01/11/26, 17:50
-
Christian Kuhn uploaded patch set 8 01/11/26, 18:03
-
Christian Kuhn updated the commit message in patch set 9 01/11/26, 18:09
-
Christian Kuhn uploaded patch set 10 01/11/26, 18:25
-
Christian Kuhn uploaded patch set 11 01/11/26, 20:44
-
Christian Kuhn uploaded patch set 12 01/11/26, 20:47
-
Christian Kuhn uploaded patch set 13 01/11/26, 20:49
-
Christian Kuhn uploaded patch set 14 01/12/26, 15:05
-
Christian Kuhn uploaded patch set 15 01/12/26, 15:31
-
Christian Kuhn uploaded patch set 16 01/12/26, 15:35
-
Christian Kuhn uploaded patch set 17 01/12/26, 16:18
-
Christian Kuhn uploaded patch set 18 01/12/26, 16:25
-
Christian Kuhn uploaded patch set 19 01/12/26, 16:28
-
Christian Kuhn uploaded patch set 20 01/12/26, 16:52
-
Christian Kuhn uploaded patch set 21 01/12/26, 16:56
-
Christian Kuhn uploaded patch set 22 01/12/26, 17:14
-
Christian Kuhn wrote 01/12/26, 17:15
Unset private -
Christian Kuhn updated the commit message in patch set 23 01/12/26, 17:18
-
Christian Kuhn updated the commit message in patch set 24 01/12/26, 17:20
-
Christian Kuhn uploaded patch set 25 01/12/26, 17:20
-
core-ci voted on patch set 22 V -1 01/12/26, 17:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93288
-
core-ci voted on patch set 23 V -1 01/12/26, 17:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93289
-
core-ci voted on patch set 24 V -1 01/12/26, 17:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93290
-
core-ci voted on patch set 25 V +1 01/12/26, 17:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93291
-
Christian Kuhn uploaded patch set 26
V +101/13/26, 13:22 -
Christian Kuhn rebased onto patch set 27 01/13/26, 13:22
-
core-ci voted on patch set 26 V +1 01/13/26, 13:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93362
-
core-ci voted on patch set 27 V +1 01/13/26, 13:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93363
-
Christian Kuhn uploaded patch set 28
V +101/13/26, 14:16 -
core-ci voted on patch set 28 V +1 01/13/26, 14:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93369
-
Christian Kuhn uploaded patch set 29
V +101/13/26, 15:57 -
core-ci voted on patch set 29 V +1 01/13/26, 16:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93385
-
Achim Fritz voted on patch set 29 CR +1 V +1 01/13/26, 16:47
-
Simon Schaufelberger commented on patch set 29 01/13/26, 18:44
NewContentElementController.php:68protected please as wellAbstractContentPagePositionMap.php:290why was this removed?BackendLayoutView.php:253protected methods don't make any sense here as nothing else is protected in this class -
Christian Kuhn commented on patch set 29 01/13/26, 19:33
AbstractContentPagePositionMap.php:290ReplygetBackendLayoutForPage() does not return null anymore.BackendLayoutView.php:253Replyhuh? of course it does make sense. and i only moved that protected method down a bit to have public methods on top. -
Christian Kuhn commented on patch set 29 01/13/26, 19:33
NewContentElementController.php:68Replydoes not matter much. but done. -
Christian Kuhn uploaded patch set 30
CR +1V +101/13/26, 19:34 -
core-ci voted on patch set 30 V +1 01/13/26, 19:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93401
-
Georg Ringer commented on patch set 30 01/13/26, 21:13
is this limited to the tsconfig provider? I don't see from reading the code that this feature is also possible when using the record provider? -
Garvin Hicking commented on patch set 30 CR +1 01/13/26, 21:21
Feature-108623-AllowContentElementRestrictionsPerColPos.rst:15```suggestion configured types of content elements (referencing :sql:`tt_content.CType` with names like "text", "textmedia", "felogin_pi1" and so on) in backend layout columns (:sql:`colPos`): The two keys :typoscript:`allowedContentTypes` ``` Something like this, because I think "Content Type" and "Content Element Type" is a bit inconsistent, and to hint people at "CType" - which has a bit of ambiguous use in documentation and core. The later examples casually reference this with key names, but I feel this is not ideally setting up the "playfield" for a feature many people will love to jump aboard, and who might not have content_defender knowhow...? I'm not happy with my specific suggestion, wdyt of dropping those two keywords in the intro somewhere?!Feature-108623-AllowContentElementRestrictionsPerColPos.rst:18```suggestion Example for a backend layout with two rows and two columns configured using Page TSConfig: ```Feature-108623-AllowContentElementRestrictionsPerColPos.rst:91```suggestion Codewise, the PSR-14 event :php:`ManipulateBackendLayoutColPosConfigurationForPageEvent` has been added. It allows manipulation ```Feature-108623-AllowContentElementRestrictionsPerColPos.rst:92I would suggest to put this in an info box to set it off a bit, maybe also move it to the end to not create an excusing mood for the cool feature? :)Feature-108623-AllowContentElementRestrictionsPerColPos.rst:102```suggestion Backed layout columns can now restrict, which content element types are allowed or disallowed inside of it. ``` -
Simon Schaufelberger commented on patch set 30 01/13/26, 22:53
BackendLayoutView.php:253Replythe constructor only has private services so even if you would extend this class, you wouldn't be able to make use of them. That's why everything should be private or protected imo. -
Christian Kuhn commented on patch set 30 01/13/26, 23:37
BackendLayoutView.php:253Replyi don't care too much in this case and would at the moment keep it like that. DI properties and methods are not the same after all. -
Christian Kuhn commented on patch set 30 01/13/26, 23:46
Feature-108623-AllowContentElementRestrictionsPerColPos.rst:15ReplyDoneFeature-108623-AllowContentElementRestrictionsPerColPos.rst:18ReplyDoneFeature-108623-AllowContentElementRestrictionsPerColPos.rst:91ReplyDoneFeature-108623-AllowContentElementRestrictionsPerColPos.rst:92ReplyI think that's fine as it. I wanted to mention it (at the end), but not have it too prominent since it is deliberately internal.Feature-108623-AllowContentElementRestrictionsPerColPos.rst:102ReplyDone -
Christian Kuhn uploaded patch set 31
CR +1V +101/13/26, 23:46
-
core-ci voted on patch set 31 V +1 01/13/26, 23:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93408
-
Garvin Hicking commented on patch set 32
V +101/14/26, 05:44Published edit on patch set 31. -
Garvin Hicking commented on patch set 32 CR +1 01/14/26, 05:45
Feature-108623-AllowContentElementRestrictionsPerColPos.rst:104```suggestion Backend layout columns can now restrict, which content element types are allowed or disallowed inside of it. ``` -
core-ci voted on patch set 32 V +1 01/14/26, 05:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93428
-
Achim Fritz voted on patch set 32 CR +1 V +1 01/14/26, 07:30
-
Oli Bartsch commented on patch set 32 01/14/26, 09:24
NewContentElementController.php:97What is the reason for moving this down here? IMO it acted like a early return to prevent database lookups for invalid requests.NewContentElementController.php:533We have those code at multiple places (here and in the data providers). What about adding and using "filterByAllowedContentTypes()" and "filterByDisallowedContentTypes()", similar to how we do it with file extensions etc. Or at least if we can not simply filter, dedicated `getAllowedContentTypes()`.Feature-108623-AllowContentElementRestrictionsPerColPos.rst:20In contrast to the `identifier` and the `slideMode`, introduced in v13 are those new options missing in the backend layout editor in the backend. Since a lot of integrators maintain layouts only via backend, we IMO need to add them there, too. -
Oli Bartsch commented on patch set 32 V -1 01/14/26, 09:36
I also encountered some unexpected behavior: Given an existing page with a selected backend layout, which is the case for most installations, I enabled the new feature and restricted the main column to a limited set of CTypes. Content elements that are not allowed are still displayed in the column without any indication. This might be acceptable for the first step. However, what is really unintended is the following behavior: when opening such a content element, its colPos and CType are effectively reduced. For example, a textmedia element is automatically converted to header, and colPos is changed to one of the allowed values or left empty if none are available. When saving the element, it is either moved to a different column or remains in the same one, but in all cases the CType is automatically changed to the first allowed value. This implicit modification of existing content elements is surprising and potentially problematic. -
Oli Bartsch commented on patch set 32 01/14/26, 09:42
NewContentElementController.php:546I am not entirely sure whether we should evaluate both values here. Doing so might lead to unintended side effects when CTypes are restricted to an allowed set, while some or all of those types are simultaneously disallowed. This is admittedly an edge case and could be considered a misconfiguration, but I wanted to bring it to attention. We might want to skip evaluating disallowed CTypes when an allowed list is already defined. -
Oli Bartsch commented on patch set 32 01/14/26, 09:55
Reply
Additionally, when translating such page, the invalid elements are not excluded, therefore displayed in the invalid column and lead to an exception in the translation step, e.g: > Failed to complete localization: [1.1]: The record "tt_content:NEW696767c6a653b237912802" with CType "shortcut" in colPos "0" couldn't be saved due to disallowed value(s). -
Christian Kuhn uploaded patch set 33
CR +1V +101/14/26, 12:44 -
Christian Kuhn commented on patch set 33 01/14/26, 12:44
Reply
> Additionally, when translating such page, the invalid elements are not excluded, therefore displayed in the invalid column and lead to an exception in the translation step, e.g: > > > Failed to complete localization: [1.1]: The record "tt_content:NEW696767c6a653b237912802" with CType "shortcut" in colPos "0" couldn't be saved due to disallowed value(s). not an exception, but a renderer error message within the wizard on my side. creating the overlay works and all valid records are created. i think that's ok for this shot, and we should have a look if we can fine tune the localization wizard with anthor patch to for instance reduce the selection and improve wording and rendering. regarding the "unexpected" changing of the selected value: this behavior is mainly a side effect of existing FormEngine restrictions and an overall missing solution for values that may have been correct when created but are not anymore for some reason. details: let's say you have a simple select with three allowed item values 'one', 'two', 'three'. add a record setting the value to 'two'. then go to TCA and remove item 'two'. open the record: item 'one' is shown as selected. 'two' is shown as "missing label" invalid value, but is not selected. when you save after opening, the stored value is changed to 'one'. this is essentially what happened here as well. only if you explicitly reset the form to the 'missing label '"two"', you can "keep" the invalid value. a patch to change the odd "invalid value is not selected" behavior has been abandoned with https://review.typo3.org/c/Packages/TYPO3.CMS/+/69912. in our case for 'colPos' and 'CType': since this is a data provider after "SelectItems", we can change the code slightly to keep invalid values, and to change the label similar to what exists with currently invalid things on select items. we can even manage to keep it selected in this case. pushed patch set 33 reflects this. datahandler has no concept to validate and enforce select values. the new hook adds this for colPos and CType: the interface still allows clicking "save", but DH then does not store the record. i think that's good as first shot and could be improved ux-wise later on by improving formEngine validation in general, but that's a bigger topic. the other option is to drop the DH hook. in general, both FormEngine and DataHandler miss good solutions for dealing with structurally invalid records. an issue we have since ever. we should also adapt at least the layout-module drag&drop code to prevent dropping a content element to a column that does not allow the type. this should happen anyway and can be done with another patch. i see 3 possible solutions: * keep solution as proposed with set 32 * adapt the formEngine data providers as proposed with set 33 * create a validation, sanitation, scanning and escalation concept, implement it and postpone the content element type based restriction. i'm unsure if we'll be able to come up with something until v15 lts. to relax related things, it might also be a good idea to have a look at the situation from https://review.typo3.org/c/Packages/TYPO3.CMS/+/69912 again.NewContentElementController.php:97Replyside effect of removing the dynamic method call. it is easier to read this way. there is no point in 'performance optimizing a 400' and the BU::readPageAccess() db query absolutely does not matter in this artificial error case that can not be triggered in projects since it would be a core bug.NewContentElementController.php:533Replyi like to keep that simple code in place. it is easy to grasp and i don't want some arbitrary helper elsewhere. the conditions, loops and bodies are also all different and the trivial static explode one-liner is not an issue.NewContentElementController.php:546Replywell, yes. i think it is obvious to everybody that this config wouldn't make too much sense: allowedContentElements = header disallowedContentElements = header i think it is good to keep that very simple, integrators should be able to debug and see this easily and we shouldn't add funny "let's ignore something if ..." magic.Feature-108623-AllowContentElementRestrictionsPerColPos.rst:20Replyyeah. i'm aware of that. we should adapt this as next patch. i changed phrasing slightly to reflect this. -
Christian Kuhn commented on patch set 33 01/14/26, 12:45
Reply
updated wording. -
core-ci voted on patch set 33 V +1 01/14/26, 12:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93438
-
Achim Fritz voted on patch set 33 CR +1 V +1 01/14/26, 13:38
-
Stefan Bürk voted on patch set 33 CR +1 01/14/26, 15:18
-
Oli Bartsch commented on patch set 33 01/14/26, 16:52
Reply
the idea behind Patchset 33 sounds good. Will check the updated state later today. Thank you for the adjustments. -
Christian Kuhn uploaded patch set 34
CR +1V +101/14/26, 17:15 -
Christian Kuhn commented on patch set 34 01/14/26, 17:15
Reply
Done -
Christian Kuhn updated the commit message in patch set 35 01/14/26, 17:16
-
Garvin Hicking voted on patch set 35 CR +1 V +1 01/14/26, 17:16
-
core-ci voted on patch set 34 V +1 01/14/26, 17:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93465
-
core-ci voted on patch set 35 V +1 01/14/26, 17:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93466
-
Stefan Bürk voted on patch set 35 CR +1 V +1 01/14/26, 17:41
-
Stefan Bürk voted on patch set 35 CR +2 V +2 01/14/26, 17:46
-
Stefan Bürk merged patch set 36 01/14/26, 17:46
NewContentElementController.php:252