2016-11-24 11 views
0

У меня есть элемент liquid_styled_content, и они имеют элементы IRRE, которые также являются элементами liquid_styled_content. Как я могу получить элементы IRRE?Отношения IRRE от tt_content до tt_content в жидкостном стиле

На данный момент я пытаюсь получить их с помощью специального DataProcessor, но я не знаю, как на самом деле получить элементы. Похоже, что родительский элемент хранит количество детей, а дети хранят uid родителя в foreign_field. Есть идеи?

У меня есть примерно ContentObjectRenderer, который у меня есть в DataProcessor, но, как мне грустно, я не знаю, как получить элементы. Я пробовал $cObj->cObjGet, но это не сработало.

ответ

2

Я старался, чтобы заставить его работать, и я сделал с моим обычаем DataProcessor. Подробнее о пользовательских 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; 
} 

И это конфигурация TypoScript

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

К сожалению, я не мог получить Ваше предложение работает, но я отправил мой пользовательский DataProcessor, который отлично работает для меня. –

+0

Perhabs это лучший пример: https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TypoScript/ContentElement/BootstrapPackageAccordion.txt – bschauer