Typo3 11: How to extend sys_file_reference with another sys_file_reference?

Viewed 31

I want to extend the sys_file_reference with a thumbnail option for videos.

I can already choose a file and save it in the backend but frontend only gives me an integer value for 0 or 1.

This is my TCA configuration:

 'poster' => [
    'exclude' => true,
    'label' => 'Thumbnail',
    'config' => [
        'type' => 'inline',

        'foreign_table' => 'sys_file_reference',
        'foreign_field' => 'uid_foreign',
        'foreign_sortby ' => 'sorting_foreign',
        'foreign_table_field' => 'tablenames',
        'foreign_label' => 'uid_local',
        'foreign_selector' => 'uid_local',
        'foreign_match_fields' => [
            'fieldname' => 'poster',
        ],

        'minitems' => 0,
        'maxitems' => 1,
        
        'appearance' => [
            'useSortable ' => 1,
            'headerThumbnail ' => [
                'field' => 'uid_local',
                'height' => '45m'
            ],
            'elementBrowserEnabled' => 1,
            'fileByUrlAllowed' => 1,
            'fileUploadAllowed' => 1,
        ],
        'overrideChildTca' => [
            'columns' => [
                'uid_local' => [
                    'config' => [
                        'appearance' => [
                            'elementBrowserType' => 'file',
                            'elementBrowserAllowed' => 'jpg,jpeg,png',
                            'elementBrowserEnabled' => 0,
                        ]
                    ]
                ]
            ]
        ],
    ],  
],
       

I've also:

  • extended the sys_file_reference sql table
  • extended FileReference php model with the new poster variable

I guess that the foreig_table section must be wrong but I can't figure it out.

1 Answers

the value you found is the number of references for that field, which TYPO3 stores in the field in the record while the true data is stored in mm-records (again sys_file_reference ;-) )
This mechanism is used everywhere, even if you insert further fields in sys_file_reference.

if you want to access the file, you need to do a second query on the relation

SELECT * FROM `sys_file_reference` 
 WHERE `tablenames` = 'sys_file_reference'
   AND `uid_foreign` = '<uid of sys_file_reference>' 
   AND `fieldname` = 'poster'

or you use a files processor

Related