'Typo3 render images with one-to-many relation by leveraging DatabaseQuery- and FilesProcessor

In the below example I want to get all images from table2 which are related to table1. So in table1 is a foreign key to table2 including a list of uids to table2 which itself is the representation of an image. "entries" has all the correct data included, but "images" is always empty.

What am I doing wrong?

dataProcessing {
  10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
  10 {
    table = table1
    as = entries

    dataProcessing {
        10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
        10 {
            references {
                table = table2
                fieldName = image
            }
            as = images
        }
    }
  }
}

In the "sys_file_reference" table the corresponding file references are available.



Solution 1:[1]

In the documentation it's written

references
Required: false
Type: string (comma separated integers), stdWrap
Default: ‘’ ‘1,303,42’

If this option contains a comma separated list of integers these are treated as uids of file references (sys_file_reference).

The corresponding file records are added to the output array.

New in version 10.3: stdWrap properties got added to the references property .

Assuming that the references are showing to table2 but saved in table1 you've to link to table1 or just omit the "table".

I don't know if the field in table1 is also called image, so you've to take the name of the field that is used in table1.
For the code snippet below I assume the values are saved in the field table1.image:

dataProcessing {
    10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
    10 {
        references {
            fieldName = image
        }
        as = images
    }
}

Furthermore the image-references might not be saved as integer values but in the form table2_123, but I expect that those values are properly resolved in references. How the values are saved depends on your TCA configuration. Details about the special notation you can find here: https://docs.typo3.org/m/typo3/reference-tca/11.5/en-us/ColumnsConfig/Type/Group/StoredDataValues.html#the-comma-list-method-default

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David