0

is it possible to extend the media type in my typo3 extension? Default fields are alternative, title, desription. How can i add a own field?

$GLOBALS['TCA']['tt_content']['types']['my_slider'] = [
        'showitem'         => '
                --palette--;' . $frontendLanguageFilePrefix . 'palette.general;general,
                --palette--;' . $languageFilePrefix . 'tt_content.palette.mediaAdjustments;mediaAdjustments,
                pi_flexform,
            --div--;' . $customLanguageFilePrefix . 'tca.tab.sliderElements,
                 assets
        ',
        'columnsOverrides' => [
            'media' => [
                'label'  => $languageFilePrefix . 'tt_content.media_references',
                'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('media', [
                    'appearance'    => [
                        'createNewRelationLinkTitle' => $languageFilePrefix . 'tt_content.media_references.addFileReference'
                    ],
                    // custom configuration for displaying fields in the overlay/reference table
                    // behaves the same as the image field.
                    'foreign_types' => $GLOBALS['TCA']['tt_content']['columns']['image']['config']['foreign_types']

                ], $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext'])
            ]
        ]
    ];
180690
  • 181
  • 2
  • 13

1 Answers1

0

if you analyze the datastructure of your TYPO3 database you will find: those fields (title and alternative) are not fields in the table sys_file but in sys_file_metadata (and in sys_file_reference for overwriting them on a specific usage)

With that knowledge you can add your fields to these tables and give them a proper rendering and behaviour.


Adding the fields to sys_file_metadata will make them available for every file as default values if the fiel is used anywhere.
If you want these fields appear only at special usage you need to set the fields only for the table sys_file_reference which is used only for relations between a file and it's usage. AND you need to set conditions to show the fields only if your content elements use a file. This condition might be a litte complicated. if you use inidvidual tables the condition could be used the usage of this foreign_table, if you use tt_content records you also need to include the CTypeof the record in the condition. Probably you will need an userfunc.
Or you have an unique fieldname?

Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38
  • No, i dont have an unique fielname. Only the CType. I tought something like If my CType then execute the Code from the sys_file_reference – 180690 Apr 27 '20 at 13:45
  • then you could use a condition to make your fields in `sys_fiel_reference` visible in the record based on the fields `tablenames` and `fieldname`. – Bernd Wilke πφ Apr 28 '20 at 08:34