简体   繁体   中英

Limit amount of content elements in a column in a backend layout of TYPO3

I have to implement a homepage in TYPO3 so that it has a different look and a different backend_layout than the subpages. In one column the editors can insert boxes as content elements. I want to have a maximum limit of boxes (or an exact amount) that can be inserted, eg 4 boxes.

Is there any way to achieve this?

The only limitation that I found was the type of content elements not their amount.

You will need to write a special PHP function for that. TYPO3 offers a system-wide principle called "hooks".

A hook can intercept the data flowing through the system and modify the behaviour of TYPO3.

There are a lot of hooks in several vital places so you should be able to tackle the issue.

In your rather special case you will need several hooks that will change the several places where an editor could add content elements. You could circumvent some of these places by disallowing the editor to see them (which might in turn reduce the amount of hooks you need to use).

Another thing you could to is to restrict the amount of content elements that are being rendered in the Frontend via Typoscript.

Take a look at select.limit.

Keep in mind that this might look odd to the editors which can't tell, why content elements they added in the BE do not show up in the frontend later.

Currently there's no easy way to configure that. The PHP class \\TYPO3\\CMS\\Backend\\View\\PageLayoutView is responsible for rendering these boxes (content elements) per page and per column (the database field is named "colPos"). Currently the only way would be to XCLASS/override the PageLayoutView class and to post-process the results of method getTable_tt_content().

A better solution would be to introduce this limiting behaviour or to add a hook that allows custom processing of the accordant data (buttons to be shown, like 'new' and 'paste').

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM