2017-03-06 3 views
0

"media"フィールドを持つカスタムコンテンツエレメントを作成しました。ここで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は、すべてのフィールドの値が含まれている「メディアフィールド」ウィッヒは空の配列です期待しています。私は流体にそれを渡すためにDataProcessでメディアファイルにアクセスするにはどうすればよい

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

:ここ

は私のTCAがどのように見えるかですか?

+0

この指示に従っていますか?いいえ、見てください:https://usetypo3.com/custom-fsc-element.html –

+0

はい私はこのチュートリアルを使ってカスタムフォームを作成しました。 tt_contentテーブルのinternal_type "file"のカスタム "my_pdf"フィールドを追加しました。私のsetup.txtでは、チュートリアルのようにFilesProcessorのreferences.fieldName = my_pdfを設定しました。しかし、$ processedData ['files']はCustomCeProcessorクラスでは空です。 – user6800816

答えて

1

TYPO3\CMS\Frontend\DataProcessing\FilesProcessorでも可能です。独自のDataProcessorを作成する必要はありません。

デバッグビューヘルパーをアクティブにすると、ファイルはmy_pdfと表示されます。

ファイルがFluidデバッグビューヘルパーで表示されていることを確認してください。

関連する問題