0

I have a fluid_styled_content element and they have IRRE elements which are also fluid_styled_content elements. How can I get the IRRE elements?

At the moment I am trying to get them with a custom DataProcessor but I don't know how to actually get the elements. It looks like, that the parent element stores the amount of children and the children are storing the uid of the parent in the foreign_field. Any ideas?

I though about the ContentObjectRenderer which I do have in the DataProcessor, but as I sad, I don't know how to actually get the elements. I tried $cObj->cObjGet but it didn't worked.

Daniel
  • 6,916
  • 2
  • 36
  • 47
Rune Piper
  • 21
  • 5

2 Answers2

2

I tried hard to get it working and I did with my custom DataProcessor. Learn more about custom DataProcessors here: https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/AddingYourOwnContentElements/Index.html#data-processor

This is the processor itself:

/**
 * @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;
}

And this is the TypoScript configuration

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
            }
        }
    }
}
Rune Piper
  • 21
  • 5
1

Have a look here:

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
            }
        }
    }
}
bschauer
  • 958
  • 9
  • 33
  • Sorry I couldn't get your suggestion running, but I posted my custom DataProcessor that works perfectly for me. – Rune Piper Nov 24 '16 at 13:30
  • Perhabs this is a better example: https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TypoScript/ContentElement/BootstrapPackageAccordion.txt – bschauer Nov 24 '16 at 13:34