Reputation: 51
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?
Upvotes: 1
Views: 414
Reputation: 25
In DCE container definition, just use
<div id="foo">
<f:for each="{dces}" as="dce">
{dce.get.title}
</f:for>
</div>
<div id="bar">
<f:for each="{dces}" as="dce">
{dce.get.bla}
</f:for>
</div>
and nothing at all in template (2nd tab of DCE defintion).
Upvotes: -1
Reputation: 51
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>
Upvotes: 0