TCA: edit sys_file_metadata columns in the context of a custom tt_content CE

59 Views Asked by At

I have developed a custom content element based on the image type of tt_content. Now I would like to edit the columns alternative, description and title (label and possibly change type and description). Since these are not columns of tt_content but sys_file_metadata, I am a bit puzzled how to achieve this. The following attempt did not lead to the goal:

$GLOBALS['TCA']['tt_content']['types']['my_custom_ce'] = [
'columnsOverrides' => [
        'image' => [
            'config' => [
                'overrideChildTca' => [
                    'assets' => [
                        'config' => [
                            'overrideChildTca' => [
                                /* some overrides */
                                ]
                            ]
                        ]
                    ]
                ],
            ],
        ],
    ],
],

Can someone please explain to me how I can change the columns of a referenced object in the context of a custom content element? I am grateful for any tips!

2

There are 2 best solutions below

2
On

As you asked the question with TYPO3 v12 tagged, you should take a closer look at https://docs.typo3.org/m/typo3/reference-tca/12.4/en-us/ColumnsConfig/Type/File/Index.html If you want to override alternative, title, etc. in your content element, the data is not stored inside sys_file_metadata, but in the reference table sys_file_reference. To use and adjust your needs, you should take TCA type file to configure your backend element.

If you not just want to override but change the values directly in sys_file_metadata (which should not be done, as this will change the fields for all relations where no override in sys_file_reference is done), you could do with https://github.com/fgtclb/typo3-file-required-attributes

0
On

I finally managed to manipulate the columns of the referenced table. The following configuration does the trick:

$GLOBALS['TCA']['tt_content']['types']['my_custom_ce'] = [
    'columnsOverrides' => [
        'image' => [
            'config' => [
                'overrideChildTca' => [
                    'columns' => [
                        'alternative' => [
                            'description' => '...',
                            'label' => '...'
                        ],
                        'description' => [
                            'description' => '...',
                            'label' => '...'
                        ],
                        'title' => [
                            'description' => '...',
                            'label' => '...'
                        ]
                    ]
                ]
            ]
        ]
    ],
]

I would have liked to change the order and title of the palette in this way, but unfortunately the following configuration has no effect:

$GLOBALS['TCA']['tt_content']['types']['my_custom_ce'] = [
    'columnsOverrides' => [
        'image' => [
            'config' => [
                'overrideChildTca' => [
                    'palettes' => [
                        'imageoverlayPalette' => [
                            'label' => '...',
                            'showitem' => 'alternative,title,--linebreak-- ,description,link,--linebreak--,crop'
                        ]
                    ]
                ]
            ]
        ]
    ],
]

If someone could explain to me how I can achieve the latter, I would be very grateful!