Automatically added system fields to content types (tt_content
)
Changed in version 13.3
Creating content elements has been simplified by removing the need to define the system fields for each element again and again. This shrinks down a content element's showitem to just the element specific fields. See also Migration. Added with Feature: #104814 - Automatically add system fields to content types.
The following tabs / palettes are added automatically to the showitem
property of table tt_
:
- The General tab with the
general
palette at the very beginning - The Language tab with the
language
palette after custom fields - The Access tab with the
hidden
andaccess
palettes - The Notes tab with the
row
fieldDescription
![The edit form of a slider with its tabs. The above mentioned ones are underlined.](../Images/ManualScreenshots/tt_content_automatic_tabs.png)
The underlined tabs are added automatically.
See Extended content element with custom fields for an example.
Note
The fields are added to the showitem through their corresponding palettes. In case such palette has been changed by extensions, the required system fields are added individually to corresponding tabs.
In case one of those palettes has been changed to no longer include the corresponding system fields, those fields are added individually depending on their definition in the Table properties (ctrl) section.
By default, all custom fields - the ones still defined in showitem - are
added after the general
palette and are therefore added to the
General tab, unless a custom tab (for example Plugin,
or Categories) is defined in between. It's also possible to start
with a custom tab by defining a --
as the first item in the
showitem. In this case, the General tab will be omitted.
All those system fields, which are added based on the ctrl
section are
also automatically removed from any custom palette and from the customized
type's showitem definition.
If the content element defines the Extended tab, it will be
inserted at the end, including all fields added to the type via API methods,
without specifying a position, via
\TYPO3\
. See
Extended content element with custom fields for an example.
Examples for the showitems
TCA section in content elements
Basic custom content element with header and bodytext
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
// Add the content element to the "Type" dropdown
ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'label' => 'My extension basic text element',
'value' => 'my_extension_basic_text',
],
);
// Add the predefined fields to the "General" tab
$GLOBALS['TCA']['tt_content']['types']['my_extension_basic_text']['showitem'] =
'--palette--;;headers,bodytext,';
The following tabs are shown, the header palette and bodytext field are shown in palette general:
![Screenshot of the content element form created by the code](../Images/ManualScreenshots/tt_content_basic.png)
Screenshot of the content element form created by the code
Extended content element with custom fields
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
// Add the content element to the "Type" dropdown
ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'label' => 'My extension custom text element with links',
'value' => 'my_extension_extended-text',
'icon' => 'my-extension-content-text',
'group' => 'default',
'description' => 'Some descripton',
],
'textmedia',
'after',
);
// Define some custom columns
$additionalColumns = [
'my_extension_link' => [
'label' => 'My link',
'config' => [
'type' => 'link',
],
],
'my_extension_link_text' => [
'label' => 'My link text',
'config' => [
'type' => 'input',
],
],
'my_extension_extra_text' => [
'label' => 'My extra text',
'config' => [
'type' => 'input',
],
],
];
// Add the custom columns to the TCA of tt_content
ExtensionManagementUtility::addTCAcolumns('tt_content', $additionalColumns);
// Add predefined and custom fields to the "General tab" and introduce a tab called "Extended"
$GLOBALS['TCA']['tt_content']['types']['my_extension_extended-text']['showitem'] = '
--palette--;;headers,
bodytext,
--div--;My tab,
my_extension_link,
my_extension_link_text,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,';
// This field will be added in tab "Extended"
ExtensionManagementUtility::addToAllTCAtypes(
'tt_content',
'my_extension_extra_text',
'my_extension_extended-text'
);
The following tabs are shown:
![Screenshot of the content element form created by the code](../Images/ManualScreenshots/tt_content_extended.png)
Screenshot of the content element form created by the code
Additional fields that are subsequently added to the end of the table using
\TYPO3\
will appear in the tab Extended.
Migration: Remove system fields from showitems on dropping TYPO3 v12.4 support
It is sufficient to apply changes to the showitem section of content types once dropping TYPO3 v12.4 support in extensions.
In site packages or extensions only supporting TYPO3 v13.3 or above you can migrate the showitem right away:
'slider' => [
'showitem' => '
- --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
- --palette--;;general,
--palette--;;headers,
slider_elements,
bodytext;LLL:EXT:awesome_slider/Resources/Private/Language/locallang_ttc.xlf:bodytext.ALT.slider_description,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:appearance,
--palette--;;frames,
--palette--;;appearanceLinks,
- --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
- --palette--;;language,
- --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
- --palette--;;hidden,
- --palette--;;access,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
categories,
- --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
- rowDescription,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
',
],
So the tabs General, Language, Access and Notes are now added automatically together with the corresponding system fields.