2016-11-24 57 views
0

我有一個fluid_styled_content元素,它們具有也是fluid_styled_content元素的IRRE元素。我如何獲得IRRE元素?流體樣式內容中從tt_content到tt_content的IRRE關係

目前我正試圖讓他們用自定義的DataProcessor,但我不知道如何實際獲取元素。它看起來像父元素存儲的孩子的數量,並且孩子正在存儲父項的uid在foreign_field中。有任何想法嗎?

雖然我在DataProcessor中有ContentObjectRenderer,但是我傷心,我不知道如何去實際獲取元素。我試過$cObj->cObjGet但它沒有奏效。

回答

2

我努力得到它的工作,我做我的自定義的數據處理器。詳細瞭解自定義DataProcessors這裏:https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/AddingYourOwnContentElements/Index.html#data-processor

這是處理器本身:

/** 
* @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) 
{ 
    $table = $processorConfiguration['references.']['table']; 
    $fieldName = $processorConfiguration['references.']['fieldName']; 

    $irreElements = $cObj->getRecords(
     $table, 
     [ 
      'where' => $fieldName.'='.$cObj->data['uid'], 
      'orderBy' => 'sorting' 
     ] 
    ); 

    $targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration); 
    $processedData[$targetVariableName] = $irreElements; 

    return $processedData; 
} 

這是Typo腳本配置

tt_content { 
    services < lib.fluidContent 
    services { 
     templateName = Services.html 
     dataProcessing { 
      23 = Vendor\ExtensionName\DataProcessing\WhateverYouWantToCallItProcessor 
      23 { 
       references.fieldName = service 
       references.table = tt_content 
       as = serviceElements 
      } 
     } 
    } 
} 
0

看一看這裏:

https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/frontend/Classes/DataProcessing/DatabaseQueryProcessor.php

tt_content { 
    accordion =< lib.default 
    accordion { 
     templateName = ABC 
     dataProcessing { 
      20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor 
      20 { 
       table = tx_irre_element 
       pidInList.field = pid 
       where { 
        data = field:uid 
        intval = 1 
        wrap = tt_content=| 
       } 

       orderBy = sorting 
       as = items 
      } 
     } 
    } 
} 
+0

抱歉,我不能讓你的建議運行,但我貼我的自定義數據處理器,完全適合我。 –

+0

Perhabs這是一個更好的例子: https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TypoScript/ContentElement/BootstrapPackageAccordion.txt – bschauer