2017-03-06 45 views
0

我创建了一个带有“媒体”字段的自定义内容元素。TYPO3:数据处理从自定义CE获取文件/媒体

这里是我的数据处理器类别:

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为了将它传递给液体?

+0

您是否按照此说明进行操作?如果没有,请看看它:https://usetypo3.com/custom-fsc-element.html –

+0

是的,我使用本教程来构建自定义窗体。我为tt_content表添加了internal_type“file”的自定义“my_pdf”字段。在我的setup.txt文件中,我为文件处理器设置了references.fieldName = my_pdf,就像在教程中一样。但是在CustomCeProcessor类中$ processedData ['files']是空的。 – user6800816

回答

1

TYPO3\CMS\Frontend\DataProcessing\FilesProcessor可以做到这一点。编写自己的DataProcessor并不是必需的。

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

请确认您的文件在Fluid debug viewhelper中可见。