Issue Bug Closed

#64881Filelist with a collection and translated metadata not working properly

Cornel Widmer 02/05/15, 17:03 updated 09/08/26, 10:03

Description

We started to make categories to build up a download repository. Every file in the filelist gets a category and a translation to display proper filenames. But it seems the handling of the filelist in the frontend is wrong when it comes to categories.

I’ll try to explain this in two cases…

*CASE 1*
_Backend_
File A (Default Language (German)) gets the category “Kategorie 1“
File A (English) gets the category “Kategorie 1“
_Frontend_
Two downloads are visible in german and also in english.

*CASE 2*
_Backend_
File A (Default Language (German)) gets the category “Kategorie 1“
File A (English) gets no category
_Frontend_
One download is visible in german and also in english.

*Problem*
We have no possibility to hide some files in a specific language. But most in the time you’ll have a file with informations in German (File A) and one in English (File B). And you want to display this only on the website in the specific language.
In this case I would do this:
Assign “Kategorie 1” to File A (Default Language (German)) and remove the category assigment on the translated record.
Assign “Kategorie 1” to File b (English) and remove the category assigment on the default language record.

*Not finally tested solution (quick and dirty fix)*
In this case we collected the files with the categories trough FAL collactions. So I’ve modified this lines of code in the file “CategoryBasedFileCollection.php” (typo3/sysext/core/Classes/Resource/Collection/CategoryBasedFileCollection.php)
@$resource = $this->getDatabaseConnection()->exec_SELECT_mm_query(
‘sys_file_metadata.file’,
‘sys_category’,
‘sys_category_record_mm’,
‘sys_file_metadata’,
‘AND sys_file_metadata.sys_language_uid IN (‘.$GLOBALS[‘TSFE’]->sys_language_uid.’, -1) AND sys_category.uid=’ . (int)$this->getItemsCriteria() .
‘ AND sys_category_record_mm.tablenames = \‘sys_file_metadata\’‘
);@

This is some kind of quick and dirty fix and not finally tested. But maybe this informations are enought to start a discussion about how filelinks should be handled on translated pages.

Reviews 3

Files 2

History 1329

Show 4 earlier messages
  1. Andrea Herzog-Kienast commented <span data-processor="relativetime" data-value="2015-02-12T15:33:03+00:00" > 02/12/15, 15:33 </span>

    I’m not sure that I really get your problem.
    I tried to test it with filelinks.
    Please take a look here and switch between the languages: http://typo37.herzogkienast.de/index.php?id=1&no_cache=1&L=1

    Is that the way it should work?

    Andrea

  2. Cornel Widmer commented <span data-processor="relativetime" data-value="2015-02-12T15:58:41+00:00" > 02/12/15, 15:58 </span>

    Andrea Herzog-Kienast wrote:
    > I’m not sure that I really get your problem.
    > I tried to test it with filelinks.
    > Please take a look here and switch between the languages: http://typo37.herzogkienast.de/index.php?id=1&no_cache=1&L=1
    >
    > Is that the way it should work?
    >
    > Andrea

    Hi Andrea

    Thanks for your example. Its not exactly what we wanted, but overall it looks better then in my test-case. Because you have only one download for a translated file. I assume you haven’t attached a category to the translated metadata for the files.

    Could you test what happens if you attach only the translated version to a category?

    In your case: what if you want to hide the file “t3rookies_gruppenheader.png” in english?
    Or the opposite: what if you want to hide the file “t3rookies_gruppenheader.png” in german?

  3. Andrea Herzog-Kienast commented and changed target version <span data-processor="relativetime" data-value="2015-02-13T14:52:07+00:00" > 02/13/15, 14:52 </span>

    Hi Cornel,
    I needed some time to test all the cases :).

    Test with different file collections Language Default: EN Translation: DE

    Test 1:
    Filecollection of a folder – metadata only in Default language

    All images will be displayed in Default language and Translation
    Default Metadata are also shown in German Translation

    *Test 2:
    Filecollection of a folder – metadata are also translated to DE*
    Everythink works fine

    *Test 3:
    Filecollection of a folder – metadata are also translated to DE. Default metadata get category.*
    But in filecollection I can’t chose Select from folder and Category.
    So same as in Test 2. Would be nice to chose also a category and a folder.

    *Test 3.2:
    Filecollection by category 1*
    Default Language shows all files with the assigned category from all folders. This works in Default language.
    No german metadata and no category is assigned.
    So IMHO no files should be shown in FE.
    But the the same files are shown as in Default Language.

    Test 4:
    Filecollection by category 1 – Part 2
    Metadata are translated. German gets another category (category 2) than the Default language.

    The translation of the filecollection has category 2. The Default Language Category 1. In German all files with category 1 are shown. But also files without a category will be shown if they have a category in default language.

    *Test 5:
    Filecollection by category 1 – Part 3*
    Default Metadata don’t have a category. So in the default language no files are shown. This works as expected.
    Even in the translation not files are shown. But the translation of the filecollection category 2 is chosen and that’s the category of the translated metadata.

    *During my tests I found some other things:*
    - If I copy a folder with images and metadata, all metadata are lost in the copied folder. This happens also if I copy a single file in another folder.
    - All files in filecollections are not referenced in fileadmin – or no reference is displayd.
    - It would also be helpful to show the assigned category in list view and also the metadata.

  1. Masod Mohmand commented and changed target version <span data-processor="relativetime" data-value="2016-04-12T13:51:36+00:00" > 04/12/16, 13:51 </span>

    We have the same problem with content element File Links and file collection with categories and “translated” files.
    We solved it with following quick and dirty code in class CategoryBasedFileCollection:

    if ($resource) {
    
                $fileUids = array();
    
                while (($record = $this->getDatabaseConnection()->sql_fetch_assoc($resource)) !== FALSE) {
    
                    $fileUid = intval($record['file']);
    
                     if(!in_array($fileUid, $fileUids, true)) {
    
                         $this->add($resourceFactory->getFileObject((int)$record['file']));
                         $fileUids[] = $fileUid;
                     }
    
                }
                $this->getDatabaseConnection()->sql_free_result($resource);
            }
  2. Gerrit Code Review pushed patch set 1 for master to change 48850 status New Under Review <span data-processor="relativetime" data-value="2016-07-08T10:32:15+00:00" > 07/08/16, 10:32 </span>

  3. Michael Binder commented and changed TYPO3 Version 6.2 8 <span data-processor="relativetime" data-value="2018-11-06T16:40:11+00:00" > 11/06/18, 16:40 </span>

    We have also the Problem in TYPO3 8.7.20 and the content elements File Links and file collection with categories and “translated” files.

    I’ve tested the Patch but it throws an exception

    'SELECT `sys_file_metadata`.`file` FROM `sys_category` INNER JOIN `sys_category_record_mm` `sys_category_record_mm` ON `sys_category_record_mm`.`uid_local` = `sys_category`.`uid` INNER JOIN `sys_file_metadata` `sys_file_metadata` ON `sys_category_record_mm`.`uid_foreign` = `sys_file_metadata`.`uid` WHERE Array': Unknown column 'Array' in 'where clause' 

    My solution was

    if (count($constraints)) {
                    $queryBuilder->where($constraints[0]);
                    array_shift($constraints);
                    foreach ($constraints as $constraint) {
                        $queryBuilder->andWhere($constraint);
                    }
                }
                $statement = $queryBuilder->execute();

    instead of

    ->where($constraints)

    Or is there any other solution for this case?

    EDIT:
    With this Patch it’s impossible to use mixed sys_file_metadata. You need to translate every metadata if you want to use this. Because there is no “ALL [sys_language_uid = -1]” in sys_file_metadata and we have no “Default”. This could break some installations.

  4. Georg Ringer changed subject Filelist with a collaction and translated metadata not working properly Filelist with a collection and translated metadata not working properly <span data-processor="relativetime" data-value="2026-02-26T20:17:59+00:00" > 02/26/26, 20:17 </span>

  5. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-09-02T09:10:10+00:00" > 09/02/26, 09:10 </span>

    Applied in changeset commit:9ed23dcd1177e3c7b1cd8e0d13fefa8de8d1e5eb.