我想禁用后端中的某些字段,例如网格元素和其他内容元素的许多领域。我知道 TCEFORM 的可能性,但它只允许禁用所有 cType 中的一个字段。我需要一种方法来仅针对某些 cType 禁用某些字段。
有办法实现这一点吗? 谢谢
如果您针对 tt_content 调整 TCA,您可以完全控制显示哪个字段。您可以使用客户扩展(站点包)覆盖 TCA。
以下文件包含字段,显示为 CType header (TYPO3 CMS 7.6)
EXT:sitepackage/配置/TCA/Overrides/tt_content.php
<?php
defined('TYPO3_MODE') or die();
call_user_func(function () {
$GLOBALS['TCA']['tt_content']['types']['header']['showitem'] = '--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.headers;headers,rowDescription,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.extended,--div--;LLL:EXT:lang/locallang_tca.xlf:sys_category.tabs.category,categories';
});
删除或添加您需要后的任何字段,并对您想要更改的任何 CType 执行此操作。 另请参阅https://docs.typo3.org/typo3cms/TCAReference/7.6/Reference/Types/Index.html
同时(自 9 LTS 起)可以通过 TsConfig:
TCEFORM.tt_content.subheader.types.text.disabled = 1
…禁用所有文本内容元素的副标题字段。
您甚至可以禁用所有 cType 的字段并定义例外:
TCEFORM.tt_content.subheader{
disabled = 1
types.text.disabled = 0
}
只要您不需要额外的条件(例如某个用户或组或页面树的特定分支来禁用这些字段),您就不应该选择 PageTSconfig 和 TCEFORM,而应选择纯 TCA 类型。
只需创建一个站点包扩展(无论如何都建议这样做),并确保在 Configuration/TCA/Overrides/tt_content.php 中为 tt_content 表提供所需的设置,以便它会自动应用。
您可以在这里找到一些有关“Sitepackages 剖析”的幻灯片:https://de.slideshare.net/benjaminkott/typo3-the-anatomy-of-sitepackages
有关 TCA 类型的更多信息可以在此处找到: https://docs.typo3.org/typo3cms/TCAReference/Types/Index.html
由于 Gridelements 仅提供布局、子项、容器和列的必填字段,因此您不应该禁用这些字段,因为这可能会破坏功能。
我想从特定页面类型
categories
的页面表单中删除30
字段,并在Configuration/TCA/Overrides/pages.php
中执行此操作:
$GLOBALS['TCA']['pages']['types'][30] = str_replace(
[
' --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,',
' categories,'
],
'',
$GLOBALS['TCA']['pages']['types'][1]
);
这会将页面类型
1
的类型定义复制到页面类型 30
并删除类别选项卡和类别字段。