SplitProcessor

The SplitProcessor allows to split values separated with a delimiter from a single database field. The result is an array that can be iterated over. Whitespaces are automatically trimmed.

Options

if

if

if
Type
if condition
Required
false
Default
''

Only if the condition is met the data processor is executed.

fieldName

fieldName

fieldName
Type
string / stdWrap
Required
true
Default
''

Name of the field to be used.

as

as

as
Type
string
Required
false
Default
defaults to the fieldName

The variable name to be used in the Fluid template.

delimiter

delimiter

delimiter
Type
string / stdWrap
Required
false
Default
Line Feed
Example
","

The field delimiter, a character separating the values.

filterIntegers

filterIntegers

filterIntegers
Type
boolean / stdWrap
Required
false
Default
0
Example
1

If set to 1, all values are being cast to int.

filterUnique

filterUnique

filterUnique
Type
boolean / stdWrap
Required
false
Default
0
Example
1

If set to 1, all duplicates will be removed.

removeEmptyEntries

removeEmptyEntries

removeEmptyEntries
Type
boolean / stdWrap
Required
false
Default
0
Example
1

If set to 1, all empty values will be removed.

Example: Splitting a URL

Please see also About the examples.

TypoScript

With the help of the SplitProcessor the following scenario is possible:

EXT:examples/Configuration/TypoScript/DataProcessors/Processors/SplitProcessor.typoscript
tt_content {
   examples_dataprocsplit =< lib.contentElement
   examples_dataprocsplit {
      templateName = DataProcSplit
      dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\SplitProcessor
      dataProcessing.10 {
         as = urlParts
         delimiter = /
         fieldName = header_link
         removeEmptyEntries = 0
         filterIntegers = 0
         filterUnique = 0
      }
   }
}
Copied!

The Fluid template

In the Fluid template then iterate over the split data:

EXT:examples/Resources/Private/Templates/ContentElements/DataProcSplit.html
<html data-namespace-typo3-fluid="true" xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
   <h2>Data in variable urlParts</h2>
   <f:debug inline="true">{urlParts}</f:debug>

   <h2>Output</h2>
   <f:for each="{urlParts}" as="part" iteration="i">
      <span class="text-primary">{part}</span>
      <f:if condition="{i.isLast} == false">/</f:if>
   </f:for>

</html>
Copied!

Output

The array now contains the split strings: