1

我正在使用出色的 DCE 扩展,并希望使用每个 Child 的字段通过 Child-DCE 在容器中循环两次。

在伪代码中是这样的:容器模板:

<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>

我怎样才能做到这一点?

4

2 回答 2

0

我已经用 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;
      }
   }

并且在 Containertemplate 中(不需要 Child 模板)

{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>
于 2017-08-19T11:47:59.033 回答
-1

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).

于 2021-02-23T16:54:43.817 回答