Bug #64881
openFilelist with a collaction and translated metadata not working properly
0%
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.
Files
Updated by Andrea Herzog-Kienast almost 10 years ago
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
Updated by Cornel Widmer almost 10 years ago
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=1Is 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?
Updated by Andrea Herzog-Kienast almost 10 years ago
- Target version set to 7.1 (Cleanup)
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.
Updated by Benni Mack over 9 years ago
- Target version changed from 7.1 (Cleanup) to 7.4 (Backend)
Updated by Susanne Moog over 9 years ago
- Target version changed from 7.4 (Backend) to 7.5
Updated by Benni Mack about 9 years ago
- Target version changed from 7.5 to 7 LTS
Updated by Masod Mohmand over 8 years ago
- Target version changed from 7 LTS to 6.2.18
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); }
Updated by Benni Mack over 8 years ago
- Target version changed from 6.2.18 to Candidate for patchlevel
Updated by Gerrit Code Review over 8 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48850
Updated by Gerrit Code Review over 8 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48850
Updated by Gerrit Code Review almost 7 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48850
Updated by Gerrit Code Review over 6 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48850
Updated by Michael Binder about 6 years ago
- TYPO3 Version changed from 6.2 to 8
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.
Updated by Gerrit Code Review almost 6 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48850
Updated by Gerrit Code Review almost 5 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/48850
Updated by Gerrit Code Review almost 5 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/48850
Updated by Gerrit Code Review over 4 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/48850