TYPO3:数据处理从自定义CE获取文件/媒体

问题描述 投票:0回答:1

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

这是我的数据处理器类:

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

如何访问 DataProcess 中的媒体文件以便将其传递给 Fluid?

typo3 typoscript fluid extbase
1个回答
1
投票

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

当您激活调试视图帮助程序时,您的文件应显示为

my_pdf

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

© www.soinside.com 2019 - 2024. All rights reserved.