流体样式内容中从tt_content到tt_content的IRRE关系

时间:2016-11-24 11:01:50

标签: typo3 fluid-styled-content

我有一个fluid_styled_content元素,它们有IRRE元素,也是fluid_styled_content元素。我怎样才能获得IRRE元素?

目前我正在尝试使用自定义DataProcessor,但我不知道如何实际获取元素。看起来,父元素存储子元素的数量,子元素将父元素的uid存储在foreign_field中。有什么想法吗?

我虽然关于我在DataProcessor中拥有的ContentObjectRenderer,但是我很难过,我不知道如何实际获取这些元素。我试过$cObj->cObjGet,但它没有用。

2 个答案:

答案 0 :(得分: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
            }
        }
    }
}

答案 1 :(得分: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
            }
        }
    }
}