[FEATURE] Adds register values to FilesContentObj 47/21747/3
authorLars Peipmann <lars@peipmann.de>
Sun, 30 Jun 2013 14:23:27 +0000 (16:23 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 6 Aug 2013 21:46:59 +0000 (23:46 +0200)
Adds FILE_NUM_CURRENT and FILES_COUNT to the register
for each file.

Use case:
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 {register:FILE_NUM_CURRENT} of {register:FILES_COUNT}
20.insertData = 1
}
}

Resolves: #49480
Releases: 6.2
Change-Id: I3eca404210ee21f73cea0860fa0be7cc39b4632f
Reviewed-on: https://review.typo3.org/21747
Reviewed-by: Lars Peipmann
Tested-by: Lars Peipmann
Tested-by: Wouter Wolters
Reviewed-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php

index d76e5a5..6e6840c 100644 (file)
@@ -140,6 +140,7 @@ class FilesContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConte
                $content = '';
                // optionSplit applied to conf to allow differnt settings per file
                $splitConf = $GLOBALS['TSFE']->tmpl->splitConfArray($conf, count($fileObjects));
+
                // Enable sorting for multiple fileObjects
                $sortingProperty = '';
                if ($conf['sorting'] || $conf['sorting.']) {
@@ -154,9 +155,14 @@ class FilesContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConte
                                }
                        });
                }
+
+               $GLOBALS['TSFE']->register['FILES_COUNT'] = count($fileObjects);
+               $fileObjectCounter = 0;
                foreach ($fileObjects as $key => $fileObject) {
+                       $GLOBALS['TSFE']->register['FILE_NUM_CURRENT'] = $fileObjectCounter;
                        $this->cObj->setCurrentFile($fileObject);
                        $content .= $this->cObj->cObjGetSingle($splitConf[$key]['renderObj'], $splitConf[$key]['renderObj.']);
+                       $fileObjectCounter++;
                }
                $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
                return $content;
@@ -191,4 +197,4 @@ class FilesContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConte
 }
 
 
-?>
\ No newline at end of file
+?>