Feature #49480
closedRegister values in FilesContentObject
100%
Description
Its not possible to retrieve the file number or total file count in renderObj of the FILES Content Object.
To render the files differential you can use the optionSplit, but sometimes it would be useful to print the file number or work with if conditions.
Of example:
10 = FILES 10 { references { table = tt_news uid.field = uid fieldName = media } renderObj = COA renderObj { 10 = TEXT 10.value = Render first file two times 10.if.isFalse.data = register:FILE_NUM_CURRENT 20 = TEXT 20.value = file } }
Updated by Gerrit Code Review almost 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/21696
Updated by Gerrit Code Review almost 11 years ago
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21747
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21747
Updated by Lars Malach over 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 3eda92a4bf158d90853624cb3057a5bb1c7cac53.
Updated by Stefan Reichelt over 10 years ago
Thanks for this patch, works very well!
I have one question on it though:
Is it intended that FILE_NUM_CURRENT/$fileObjectCounter starts off with 0 and/or is only increased after the current file has been rendered?
The problem I see with how it currently is, that by the time we reach the last file to be rendered, FILE_NUM_CURRENT will still be one short of FILES_COUNT and fe. the TS example (renderObj.20.value) given would output 'file 6 of 7' (if you have 7 files in total that is).
This could lead to (initial) confusion and also makes it harder/more complex to use in some cases. Fe. if you wanted to check if you've reached the last file:
--
30 = TEXT
30.value = Yay, last file!
30.if.equals.data = register:FILE_NUM_CURRENT
30.if.value.data = register:FILES_COUNT
30.if.value.stdWrap.wrap = |-1
30.if.value.prioriCalc = 1
--
Unless of course there is an easier way to it that I'm missing at the moment.
PS: Wasn't sure where to best ask this, whether personally to Lars's mail, in a TYPO3 mailist or here. Sorry if I'm wrong though.
Updated by Lars Malach over 10 years ago
Hi Stefan,
thanks for your message. Wouter Wolters asked the same question:
Jul 16 8:14 PM - Wouter Wolters:
$key + 1? Otherwise you have Render first file two times file 0 of 2 file 1 of 2
Jul 18 11:22 PM - Lars Peipmann
IMAGE_NUM_CURRENT in ./sysext/css_styled_content/Classes/Controller/CssStyledContentController.php starts also with 0... Should be the same behavior here, shouldn't it?
Jul 29 12:07 AM - Wouter Wolters
Hmm, should be the same. But it looks really weird this way...
I created a new issue and uploaded a patch to solve your problem:
https://forge.typo3.org/issues/51008
Best, Lars