user6800816
user6800816

Reputation: 543

TYPO3: Data processing get file / media from custom CE

I created a custom content element with a "media" field.

Here is my Data Processor Class:

class CustomCeProcessor implements DataProcessorInterface
{

    /**
     * Process data for the content element "My new content element"
     *
     * @param ContentObjectRenderer $cObj The data of the content element or page
     * @param array $contentObjectConfiguration The configuration of Content Object
     * @param array $processorConfiguration The configuration of this processor
     * @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View)
     * @return array the processed data as key/value store
     */
    public function process(
        ContentObjectRenderer $cObj,
        array $contentObjectConfiguration,
        array $processorConfiguration,
        array $processedData
    )
    {
        $processedData['foo'] = 'This variable will be passed to Fluid';
        return $processedData;
    }
}

$processedData contains the value for every fields expect the "media field" which is an empty array.

Here is how my TCA looks like:

$GLOBALS['TCA']['tt_content']['types']['custom_ce'] = [
    'showitem'         => '
            --palette--;' . $frontendLanguageFilePrefix . 'palette.general;general,
            --linebreak--, header;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:header_formlabel,
            --linebreak--, date;Datum,
            --linebreak--, media;Media,
            --linebreak--, bodytext;txt,
    '
];

How can I access the media file in the DataProcess in order to pass it to fluid?

Upvotes: 0

Views: 1091

Answers (1)

Stefan Padberg
Stefan Padberg

Reputation: 527

The TYPO3\CMS\Frontend\DataProcessing\FilesProcessor can do that. It is not neccessary to write an own DataProcessor.

Your file should show up as my_pdf when you activate the debug viewhelper.

Please verify that your file is visible with the Fluid debug viewhelper.

Upvotes: 1

Related Questions