0

是否可以在我的typo3 扩展中扩展媒体类型?默认字段是替代、标题、描述。如何添加自己的字段?

$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'])
            ]
        ]
    ];
4

1 回答 1

0

如果您分析 TYPO3 数据库的数据结构,您会发现:这些字段 (titlealternative) 不是表中的字段,sys_file而是在sys_file_metadata( 并在sys_file_reference特定用途上覆盖它们)

有了这些知识,您可以将字段添加到这些表中,并为它们提供适当的呈现和行为。


如果在任何地方使用该字段,则添加字段sys_file_metadata将使它们作为默认值可用于每个文件。
如果您希望这些字段仅在特殊用途时出现,您需要仅为表设置字段,该表sys_file_reference仅用于文件与其用途之间的关系。并且您需要设置条件以仅当您的内容元素使用文件时才显示字段。这种情况可能有点复杂。如果您使用个别表格,则可以使用 this 的用法foreign_table,如果您使用tt_content记录,则还需要CType在条件中包含记录的 。可能你需要一个userfunc.
或者你有一个唯一的字段名?

于 2020-04-27T12:23:45.110 回答