简体   繁体   English

限制TYPO3后端布局中列中的内容元素数量

[英]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. 我必须在TYPO3中实现一个主页,以便它具有与子页面不同的外观和不同的backend_layout 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. 我希望可以插入最大限度的盒子(或精确数量),例如4盒。

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. 您需要为此编写一个特殊的PHP函数。 TYPO3 offers a system-wide principle called "hooks". TYPO3提供了一种称为“钩子”的系统原则。

A hook can intercept the data flowing through the system and modify the behaviour of TYPO3. 钩子可以拦截流经系统的数据并修改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. 另一件事是限制通过Typoscript在前端渲染的内容元素的数量。

Take a look at select.limit. 看看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. 请记住,这对于编辑者来说可能看起来很奇怪,这些编辑者无法分辨,为什么他们在BE中添加的内容元素以后不会出现在前端。

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"). PHP类\\ TYPO3 \\ CMS \\ Backend \\ View \\ PageLayoutView负责每页和每列呈现这些框(内容元素)(数据库字段名为“colPos”)。 Currently the only way would be to XCLASS/override the PageLayoutView class and to post-process the results of method getTable_tt_content(). 目前唯一的方法是使用XCLASS /覆盖PageLayoutView类并对方法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'). 一个更好的解决方案是引入这种限制行为或添加一个钩子,允许自定义处理一致数据(按钮显示,如'new'和'paste')。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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