Bug #45724

FILES.folders does not work

Added by Maarten Mandemaker over 7 years ago. Updated about 2 years ago.

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

100%

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

Associated revisions

Revision b37265b2 (diff)
Added by Stefan Froemken almost 7 years ago

[BUGFIX] FILES.folder does not work

cObject IMAGE was executed with empty values
because given key contains filenames instead of
numbers

Resolves: #45724
Releases: 6.2, 6.1, 6.0
Change-Id: I5582b63080b7e6124c3780a8430efb410876a662
Reviewed-on: https://review.typo3.org/25016
Reviewed-by: Gernot Ploiner
Tested-by: Gernot Ploiner
Reviewed-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind

Revision ecd873fb (diff)
Added by Stefan Froemken almost 7 years ago

[BUGFIX] FILES.folder does not work

cObject IMAGE was executed with empty values
because given key contains filenames instead of
numbers

Resolves: #45724
Releases: 6.2, 6.1, 6.0
Change-Id: I5582b63080b7e6124c3780a8430efb410876a662
Reviewed-on: https://review.typo3.org/25411
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind

Revision 62f7e877 (diff)
Added by Stefan Froemken almost 7 years ago

[BUGFIX] FILES.folder does not work

cObject IMAGE was executed with empty values
because given key contains filenames instead of
numbers

Resolves: #45724
Releases: 6.2, 6.1, 6.0
Change-Id: I5582b63080b7e6124c3780a8430efb410876a662
Reviewed-on: https://review.typo3.org/25410
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind

History

#1 Updated by Markus Bischof over 7 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

#2 Updated by Andreas Dörler over 7 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

#3 Updated by Florian Rothenaicher over 7 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

#4 Updated by Gernot Ploiner about 7 years ago

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

#5 Updated by Gerrit Code Review about 7 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

#6 Updated by Gerrit Code Review almost 7 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

#7 Updated by Gerrit Code Review almost 7 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

#8 Updated by Stefan Froemken almost 7 years ago

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

#9 Updated by Benni Mack about 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF