[英]TYPO3 Media-Emelent own field
is it possible to extend the media type in my typo3 extension?是否可以在我的 typo3 扩展中扩展媒体类型? 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'])
]
]
];
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)如果您分析 TYPO3 数据库的数据结构,您会发现:这些字段(
title
和alternative
)不是表sys_file
中的字段,而是sys_file_metadata
中的字段(并且在sys_file_reference
中用于在特定用途上覆盖它们)
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.如果在任何地方使用该字段,则将字段添加到
sys_file_metadata
将使它们作为默认值可用于每个文件。
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.如果您希望这些字段仅在特殊用途中出现,您需要仅为表
sys_file_reference
设置字段,该表仅用于文件与其用途之间的关系。 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 CType
of the record in the condition.如果您使用单独的表,则可以使用这个
foreign_table
的使用条件,如果您使用tt_content
记录,您还需要在条件中包含记录的CType
。 Probably you will need an userfunc
.可能你需要一个
userfunc
。
Or you have an unique fieldname?或者你有一个唯一的字段名?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.