I have image manipulation setup on images only
and images and text
content elements of my typo3 version. It shows different image formats as shown below.
Now I want to add a select dropdown by which one of the four image formats can be selected and saved in the databank. I am successfully able to create a select dropdown and a new column in the tt_content table. The values are being updated in the DB. Although, I am able to position the select dropdown in the 'general' or 'access' tab of a content element
My problem is that, for some reason, i fail to make the select dropdown appear in the 'images' tab. Could someone one guide my why replacing 'image' with 'general' in the code below is not working?
My code:
$temporaryColumn = array(
'image_format' => array (
'exclude' => 0,
'label' => 'Image format',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['Default',0,],
['Quadrat',1,],
['Landscape',2,],
['Portrait',3,],
['Teaser',4,],
],
'size' => 1,
'maxitems' => 1,
]
)
);
$table = 'tt_content';
$column = 'image_format';
$GLOBALS['TCA'][$table]['columns'][$column] = $temporaryColumn;
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
$temporaryColumn
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'general',
'image_format',
);
You are calling addFieldsToPalette()
. So you are putting the field into a palette, not directly into a tab. This is why you must use the identifier of an existing palette as the second parameter.
tt_content
has the following palettes:
As you can see, there are palettes "general" and "access" (beside tabs with the same names). But there doesn't exist a palette "image".
Pick an existing palette and add the new field via ExtensionManagementUtility::addFieldsToPalette()
:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'mediaAdjustments',
'image_format',
);
That can be done by placing the field at a certain position in the showitem
-list of the appropriate type
. The easiest way is using ExtensionManagementUtility::addToAllTCAtypes()
:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tt_content',
'image_format',
'',
'before:image'
);