CommaSeparatedValueProcessor implements DataProcessorInterface

This data processor will take field data formatted as a string, where each line, separated by line feed, represents a row. By default columns are separated by the delimiter character "comma ,", and can be enclosed by the character 'quotation mark "', like the default in a regular CSV file.

An example of such a field is "bodytext" in the CType "table".

The table data is transformed to a multi dimensional array, taking the delimiter and enclosure into account, before it is passed to the view.

Example field data:

This is row 1 column 1|This is row 1 column 2|This is row 1 column 3 This is row 2 column 1|This is row 2 column 2|This is row 2 column 3 This is row 3 column 1|This is row 3 column 2|This is row 3 column 3

Example TypoScript configuration:

10 = TYPO3\CMS\Frontend\DataProcessing\CommaSeparatedValueProcessor 10 { if.isTrue.field = bodytext fieldName = bodytext fieldDelimiter = | fieldEnclosure = ' maximumColumns = 2 as = table }

whereas "table" can be used as a variable {table} inside Fluid for iteration.

Using maximumColumns limits the amount of columns in the multi dimensional array. In the example, field data of the last column will be stripped off.

Multi line cells are taken into account.

Table of Contents

Interfaces

DataProcessorInterface
Interface for data processor classes processing data from ContentObjectRenderer, used e.g. with the FLUIDTEMPLATE content object

Methods

process()  : array<string|int, mixed>
Process CSV field data to split into a multi dimensional array

Methods

process()

Process CSV field data to split into a multi dimensional array

public process(ContentObjectRenderer $cObj, array<string|int, mixed> $contentObjectConfiguration, array<string|int, mixed> $processorConfiguration, array<string|int, mixed> $processedData) : array<string|int, mixed>
Parameters
$cObj : ContentObjectRenderer

The data of the content element or page

$contentObjectConfiguration : array<string|int, mixed>

The configuration of Content Object

$processorConfiguration : array<string|int, mixed>

The configuration of this processor

$processedData : array<string|int, mixed>

Key/value store of processed data (e.g. to be passed to a Fluid View)

Return values
array<string|int, mixed>

the processed data as key/value store


        
On this page

Search results