[TYPO3-english] tt_content.pi_flexform reading, modiying, writing

Jigal van Hemert jigal.van.hemert at typo3.org
Tue May 12 11:19:41 CEST 2015


Hi,

On 12/05/2015 09:51, bernd wilke wrote:
> due to development we have a lot of content elements (CE) with an
> out-of-date structure in the pi_flexform.
> I have to update the data to the current datastructure, but have no clue
> how to read, modify and write back the structure in tt_content.pi_flexform.
>
> I found a lot of tips, but every combination of functions I use:
> I never get back the same XML-structure.
>
> here is an example for the nearest. the endresult has nearly the same
> number of nodes on each level, but the tags have very differnt names and
> attributes:
>
> $decodeFlexFormArray =
> \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($record['pi_flexform']);

That's a good start. If you look at the flexform definition the "index" 
attributes define the tag name in the resulting array (numeric "index" 
attribute value indicates that it's a repeated block with numeric array 
keys)

After you change the array you can simply let DataHandler (aka TCEmain) 
take care of storing it again. No need to transform it back to XML at all!

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-english mailing list