[FEATURE] Get flexform data in getText() 39/49639/3
authorGeorg Ringer <georg.ringer@gmail.com>
Tue, 30 Aug 2016 07:45:49 +0000 (09:45 +0200)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Wed, 31 Aug 2016 11:46:49 +0000 (13:46 +0200)
It is now possible to access the content of a flexform property
in TypoScript.

Resolves: #17309
Releases: master
Change-Id: I80c68597908fc16083c52dc135abbebf94179e4c
Reviewed-on: https://review.typo3.org/49639
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/core/Documentation/Changelog/master/Feature-17309-AccessFlexformValueViaTS.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-17309-AccessFlexformValueViaTS.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-17309-AccessFlexformValueViaTS.rst
new file mode 100644 (file)
index 0000000..3977d55
--- /dev/null
@@ -0,0 +1,28 @@
+==============================================
+Feature: #17309 - Access flexform value via TS
+==============================================
+
+Description
+===========
+
+It is now possible to access properties of a flexform field by using TypoScript.
+
+.. code-block:: typoscript
+
+    lib.flexformContent = CONTENT
+    lib.flexformContent {
+        table = tt_content
+        select {
+            pidInList = this
+        }
+
+        renderObj = COA
+        renderObj {
+            10 = TEXT
+            10 {
+                data = flexform: pi_flexform:settings.categories
+            }
+        }
+    }
+
+The key ``flexform`` is followed by the field which holds the flexform data and the name of the property whose content should be retrieved.
\ No newline at end of file
index 9307be1..c760ece 100644 (file)
@@ -47,6 +47,7 @@ use TYPO3\CMS\Core\Utility\MailUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
+use TYPO3\CMS\Extbase\Service\FlexFormService;
 use TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException;
 use TYPO3\CMS\Frontend\ContentObject\Exception\ExceptionHandlerInterface;
 use TYPO3\CMS\Frontend\ContentObject\Exception\ProductionExceptionHandler;
@@ -5472,6 +5473,18 @@ class ContentObjectRenderer
                                 break;
                         }
                         break;
+                    case 'flexform':
+                        $keyParts = GeneralUtility::trimExplode(':', $key, true);
+                        if (count($keyParts) === 2 && isset($this->data[$keyParts[0]])) {
+                            $flexFormContent = $this->data[$keyParts[0]];
+                            if (!empty($flexFormContent)) {
+                                $flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
+                                $flexFormKey = str_replace('.', '|', $keyParts[1]);
+                                $settings = $flexFormService->convertFlexFormContentToArray($flexFormContent);
+                                $retVal = $this->getGlobal($flexFormKey, $settings);
+                            }
+                        }
+                        break;
                 }
             }
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'])) {