Reputation: 166
I have an extension with a content element. I want to display it in the content element wizard. For this, I created tt_content.php. The code in it looks like this:
$GLOBALS['TCA']['tt_content']['types']['extensionkey_contentelementname'] = array(
'types' => [
'0' => [
'showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general, category, subject, message,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, personal
',
],
]
);
(I obviously replaced extensionkey_contentelementname with the real name)
This throws me an error when trying to create the content element:
No or invalid showitem definition in TCA table tt_content for type extensionkey_contentelementname
What did I do wrong?
Upvotes: 0
Views: 1828
Reputation: 376
In Configuration/TCA/Overrides/tt_content.php:
$GLOBALS['TCA']['tt_content']['types']['extensionkey_contentelementname'] = [
'showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general, category, subject, message,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, personal
',
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'My content element',
'extensionkey_contentelementname',
'content-image',
],
'textmedia',
'after'
);
You got a duplicate 'types' there.
Use this in page TS config to have it in the content element wizard.
$GLOBALS['TCA']['tt_content']['types']['extensionkey_contentelementname'] = [
'showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general, category, subject, message,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, personal
',
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'My content element',
'extensionkey_contentelementname',
'content-image',
],
'textmedia',
'after'
);
Upvotes: 2
Reputation: 2592
You are adding two array levels too much. You are already in $GLOBALS['TCA']['tt_content']['types']
, so the types
and 0
is not needed anymore.
Upvotes: 2