Bug #45724
closedFILES.folders does not work
100%
Description
This TS does not seem to work:
page.10 >
page.10 = FILES
page.10 {
folders = 1:images/
}
page.10.renderObj = TEXT
page.10.renderObj {
data = file:current:size
wrap = <p class="alert">File size:<strong>|</strong></p>
}
Should work according to:
http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Files/Index.html
Updated by Markus Bischof over 11 years ago
I can confirm this. I have a folder named images an tried
20 = FILES
20 {
folders = 1:images/
renderObj = TEXT
renderObj {
data = file:current:title // file:current:name
wrap = <br>|
}
}
and it did not work!
Working with Typo3 6.0.4
Updated by Andreas Dörler over 11 years ago
Hi,
I think, I’ve found the cause of this problem and can provide two possible solutions:
For testing purposes we add two already (FAL-) indexed files to a collection with e.g. sys_file_collection UID=2 and two other files are placed by FTP into the fileadmin-directory (Storage with storageUid=1, folderIdentifier "images" => so that they are not available in FAL-tables).
Consider the followingTyposcript:
page.10 > page.10 = FILES page.10 { folders = 1:images/ collections = 2 }
If you rendert he page unsing the renderObj shown in the original Bugreport, only the files within the collection are shown.
Walking through the code shows:
typo3\sysext\frontend\Classes\ContentObject\FilesContentObject.php function render Line 154: foreach ($fileObjects as $key => $fileObject) { $this->cObj->setCurrentFile($fileObject); $content .= $this->cObj->cObjGetSingle($splitConf[$key]['renderObj'], $splitConf[$key]['renderObj.']); }
The $fileObjects contains 4 entries, which would be corret, but the files from the collection are stored with an integer based array-key and the files from folder have their filename as array-key.
You can see in the getFiles function, that the „folder-files“ have their filename set as key:
typo3\sysext\core\Classes\Resource\Folder.php function getFiles Line 201: $fileObjects[$fileInfo['name']] = $factory->createFileObject($fileInfo);
Now the problem is, that the $splitConf is an integer based array, therefore no splitconf will be found for the „folder-fileObjects“, due to a „wrong key“ in the foreach statement.
There are two possible solutions:- Either use a counter within the foreach instead of „$key“ to access the corresponding $splitConf
- Or remove the „$fileInfo['name']“ while adding folder files to the $fileObjects in getFiles-function.
Both will work, but I do not know if the Array-key created in getFiles is used somewhere else in the code.
Kind regards
Andreas
Updated by Florian Rothenaicher over 11 years ago
Hello,
i can confirm this too on TYPO3 6.1.2. We solved this by adding array_values()-function:
typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php line 126: Old: $this->addToArray($folder->getFiles(), $fileObjects); New: $this->addToArray(array_values($folder->getFiles()), $fileObjects);
Kind regards,
Florian
Updated by Gernot Ploiner about 11 years ago
Same Problem in TYPO3 6.1.5
Florian's Solution works perfect for me.
Updated by Gerrit Code Review about 11 years ago
- Status changed from New to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/25016
Updated by Gerrit Code Review about 11 years ago
Patch set 1 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25410
Updated by Gerrit Code Review about 11 years ago
Patch set 1 for branch TYPO3_6-0 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25411
Updated by Stefan Froemken about 11 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 62f7e877732d465c76538ec5cc07ef3d11b60394.