DCE Container Loop

I'm using the excellent DCE Extension and want to loop twice in the Container through the Child-DCEs using the fields of each Child.

In Pseudocode something like this: Container Template:

<div id="foo">
<f:for each="{dces}" as="dce">
    {dce.fields.title}
</f:for>
</div>
<div id="bar">
<f:for each="{dces}" as="dce">
    {dce.fields.bla}
</f:for></div>

How can I do that?

728x90

1 Answers DCE Container Loop

I've solved the problem with a Viewhelper:

class DcevalViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
    /**
      * @param ArminVieweg\Dce\Domain\Model\Dce object
      *
      * @return array
      *
      */
    public function render($dce) {
      $contentObject = $dce->getContentObject();
      $temp = GeneralUtility::xml2array($contentObject['pi_flexform']);
      $temp = $temp['data']['sheet.tabGeneral']['lDEF'];
      foreach($temp as $key=>$val)  {
         preg_replace( "/\r|\n/", "", $val['vDEF'] );
         $dcedata[substr($key,9)]=$val['vDEF'];
         }
      $dcedata['uid']=$contentObject['uid'];
      return $dcedata;
      }
   }

And in the Containertemplate (no need for a Child template)

{namespace dce=ArminVieweg\Dce\ViewHelpers}
{namespace tom=Mediagmbh\Tomediavh\ViewHelpers}

<f:layout name="DefaultContainer" />

<f:section name="main">
<div id="foo">
<ul>
<f:for each="{dces}" as="dce">
  <f:alias map="{field:'{tom:Dceval(dce:dce)}'}">
  <li>{field.header}</li>
  </f:alias>
</f:for>
</ul>
</div

<div id="bar">
<f:for each="{dces}" as="dce">
  <f:alias map="{field:'{tom:Dceval(dce:dce)}'}">
  <div><f:format.raw>{field.text}</f:format.raw></div>
  </f:alias>
</f:for>
</div>
</div>

</f:section>

2 year ago