Review main Ready for review

94788[FEATURE] Allow limiting content elements per colPos

Josua Vogel CR 0 V 0 Nightmare +2807 −12 updated 11/16/26, 14:59

Commit message

Backend layout columns restrict which content elements they accept,
through "allowedContentTypes" and "disallowedContentTypes". There was
no way to restrict how many. A column meant to hold one element, such
as a hero, a pre-footer or a sidebar teaser, could so far only be
limited by a project specific DataHandler hook.

The new column key "maxItems" is that restriction. It limits how many
content elements a column shows at the same time. Hidden elements do
not count, and an element with a start or end time only counts during
that period. Editors can prepare a hidden successor or schedule one
for when the current element ends, which is how such columns are
maintained in practice. Since overlapping periods are checked when an
element is saved, a start time that is reached later never makes a
column exceed its limit.

The page module draws how many elements a column shows next to its
title. In a full column the "new content element" wizard creates the
element hidden. Pasting a cut element and the drop zones for visible
elements from other columns are not offered there. The DataHandler
enforces the limit for creating and saving a record, showing it,
changing its start or end time, copying, moving, pasting, localizing,
undeleting, and for publishing a workspace version into a live column
that was filled in the meantime. A copy hidden by "hideAtCopy" does
not count.

Connected translations follow their record into another column and
are checked in their own language. New records are checked against
the column their default values put them in and against a page
created in the same job list; one that does not fit is saved hidden,
or refused if the editor may not edit the hidden field.
An existing record whose change is refused keeps its column and
visibility, its other changes are saved. Hiding an element or
shortening the time it is shown is always accepted, so a column that
already holds too much can be cleaned up. Copying a whole page and
importing data reproduce a structure as it is and are not restricted.

Counting is workspace aware and happens per language: an element added
in a workspace counts there and one deleted in it does not. An element
set to "All languages" counts against every language.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 6
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/88/94788/6 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/88/94788/6 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 26

Issues 1

Files 27

Show 7 more files

Review log 1622

  1. Josua Vogel uploaded patch set 1 07/15/26, 10:06

  2. core-ci voted on patch set 1 V +1 07/15/26, 10:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104783

  3. Stefan Bürk commented on patch set 1 07/15/26, 15:09

    I guess that needs workspace aware thoughts and handlings ? Item deleted and another added in the workspace. And also dealing during workspace pulish in case another workspace has been published or in live workspace the limit reached - how should workspace deal with that case ? TBH not tested or looked into it, just wanted to mention custom thoughts in a early phase of it.
  4. Josua Vogel commented on patch set 1 07/15/26, 15:15

    Reply

    Thanks for your thoughts! It´s a PoC, because I want this for a customer 😊 But I´ll have a look at the workspace handling soon
  5. Josua Vogel uploaded patch set 2 V +1 09/08/26, 11:26

  6. core-ci voted on patch set 2 V +1 09/08/26, 11:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108085

  7. Josua Vogel uploaded patch set 3 V +1 09/08/26, 11:45

  8. core-ci voted on patch set 3 V +1 09/08/26, 11:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108089

  9. Lukas Dörr commented on patch set 3 CR +1 V +1 09/11/26, 11:03

    works great. I think this should be in core :) well done!
  10. Josua Vogel commented on patch set 3 09/11/26, 15:10

    Reply

    Acknowledged
  11. Daniel Windloff commented on patch set 3 09/14/26, 06:10

    DataHandlerColumnMaxItemsHook.php:38

    In my point of view, the restriction cannot be sensibly encapsulated in a hook. I would integrate it directly into the DH, even though that is already significantly too large.

    DataHandlerColumnMaxItemsHook.php:71

    Default values are not fully resolved yet. This will not work properly. I had the same issue while refactoring the other colpos related hook: https://review.typo3.org/c/Packages/TYPO3.CMS/+/90484

    DataHandlerColumnMaxItemsHook.php:80

    Pid can be a NEW placeholder. It will be resolved later. So if the pid is a string, it the dataMap could be checked for other entries with the same pid.

    DataHandlerColumnMaxItemsHook.php:410

    All as lang should be considered as well
  12. Josua Vogel uploaded patch set 4 CR +1 V +1 10/22/26, 19:13

  13. Josua Vogel commented on patch set 4 10/22/26, 19:16

    DataHandlerColumnMaxItemsHook.php:38 Reply

    I kept it as a hook on purpose: the existing column restriction is implemented the same way in DataHandlerContentElementRestrictionHook. Both restrictions belong to backend layouts, so I think it´s a good match inside ext:backend.

    DataHandlerColumnMaxItemsHook.php:71 Reply

    Done – the change now sits on top of #90484 and resolves the defaults of new records with DefaultValuesResolver.

    DataHandlerColumnMaxItemsHook.php:80 Reply

    Done – new records are checked in processDatamap_preProcessFieldArray, where NEW pids are resolved via substNEWwithIDs.

    DataHandlerColumnMaxItemsHook.php:410 Reply

    Done – counting is now per column and language; an 'All languages' element counts against every language and needs room in the fullest one.
  14. core-ci voted on patch set 4 V +1 10/22/26, 19:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112177

  15. Benni Mack commented on patch set 4 10/23/26, 14:18

    DataHandlerColumnMaxItemsHook.php:38 Reply

    I would like to keep as much of "tt_content" out of EXT:core if possible
  16. Josua Vogel commented on patch set 4 10/25/26, 19:35

    DataHandlerColumnMaxItemsHook.php:38 Reply

    Acknowledged
  17. Oli Bartsch commented on patch set 4 10/25/26, 22:22

    I think we need to talk about this. Editors usually add multiple elements and manage visibility via enable fields (hidden/starttime/endtime). This in my opinion is quite a common and valid use case, which should not be blocked by this.
  18. Oli Bartsch uploaded patch set 5 V +1 11/11/26, 21:04

  19. core-ci voted on patch set 5 V -1 11/11/26, 21:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114145

  20. Josua Vogel uploaded patch set 6 V -1 11/15/26, 18:53

  21. core-ci voted on patch set 6 V +1 11/15/26, 18:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114558

  22. Josua Vogel commented on patch set 6 11/16/26, 14:59

    Reply

    We discussed this on Slack and agreed that “hidden” doesn't count and that starttime and endtime should be included.