Project

General

Profile

Actions

Bug #45724

closed

FILES.folders does not work

Added by Maarten Mandemaker over 11 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2013-02-21
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.0
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

Actions #1

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

Actions #2

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

Actions #3

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

Actions #4

Updated by Gernot Ploiner about 11 years ago

Same Problem in TYPO3 6.1.5
Florian's Solution works perfect for me.

Actions #5

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

Actions #6

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

Actions #7

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

Actions #8

Updated by Stefan Froemken about 11 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #9

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF