Typo3 类型3:数据处理从自定义CE获取文件/介质

Typo3 类型3:数据处理从自定义CE获取文件/介质,typo3,typoscript,fluid,extbase,Typo3,Typoscript,Fluid,Extbase,我创建了一个带有“媒体”字段的自定义内容元素 以下是我的数据处理器类: class CustomCeProcessor implements DataProcessorInterface { /** * Process data for the content element "My new content element" * * @param ContentObjectRenderer $cObj The data of the content ele

我创建了一个带有“媒体”字段的自定义内容元素

以下是我的数据处理器类:

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包含除“媒体字段”以外的每个字段的值,该字段为空数组

以下是我的TCA的外观:

$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,
    '
];

如何访问数据处理中的媒体文件以将其传递给fluid?

TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
可以做到这一点。没有必要编写自己的数据处理器

激活调试视图帮助程序时,文件应显示为
my\u pdf


请使用Fluid debug viewhelper验证您的文件是否可见。

是否遵循了此说明?如果没有,请看一看:是的,我使用本教程构建自定义表单。我为tt_内容表添加了一个内部类型为“file”的自定义“my_pdf”字段。在my setup.txt中,我为文件处理器设置了:references.fieldName=my_pdf,如教程中所示。但是$processedData['files']在CustomCeProcessor类中为空。