2016-11-01 6 views
0

私は、流体を使用して重複エントリを消去する方法を見つけようとしています。アイデアはf:aliasを使用して、同じタイトルのアイテムを数えることでした。流体を使用した重複エントリのフィルタリング/消去

しかし、私の結果はばかげている。カウントは完全に間違っています。 流体のようなものを全体的に行うことは可能でしょうか?

私はこのように試してみました:

<f:alias map="{client: '{newsItem->f:count()}'}"> 
     <f:if condition="{client -> f:count()}==1"> 
      <f:then> 
       <f:if condition="{newsItem.teaser}">   

        <f:then> 
         <span itemprop="description">{newsItem.teaser -> f:format.crop(maxCharacters: '{settings.cropMaxCharacters}', respectWordBoundaries:'1') -> f:format.html()}</span> 
        </f:then> 
        <f:else> 
         <p>There are {newsItem} records in database</p> 
         <li>{newsItem.txPblcexpandnewsClient}</li>  
        </f:else> 
       </f:if> 
      </f:then> 
      <f:else> 
       else 1  
      </f:else> 
     </f:if>   
    </f:alias> 

Besteは青

答えて

1

流体は、論理的文脈のために重くするために使用するべきではありません

について。それが複雑であれば、コントローラーに属します。

しかし、タイトルでグループ化されたグループViewHelperを使用しようとします。

0

ルネは既に言ったように、この種の論理を流体で避けてください!

流体内でオンザフライで変数を定義して変更するには、ext:vhsを使用します。
だから、(私は、このドイツ語の翻訳を知らない) 'Gruppenverarbeitung' を行うことができます。

<v:variable.set name="lastitem" value="" /> 
 
<f:for each="items" as="item" iteration="iterator"> 
 
    <f:if condition="{lastitem}"> 
 
    <f:then> 
 
     <f:if condition="{lastitem.title} == {item.title}"> 
 
     <f:then> 
 
      <f:comment>just one item more</f:comment> 
 
      <v:variable.set name="counter"> 
 
      <f:cObject typoscriptObjectPath="lib.calc">{counter}+1</f:cObject> 
 
      </v:variable.set> 
 
     </f:then> 
 
     <f:else> 
 
      <f:comment>output last item</f:comment> 
 
      <f:render partial="showItem" arguments="{item:lastitem, counter:counter}" /> 
 
      <f:comment>store new item, reset counter</f:comment> 
 
      <v:variable.set name="lastitem" value="{item}" /> 
 
      <v:variable.set name="counter" value="1" /> 
 
     </f:else> 
 
     </f:if> 
 
    </f:then> 
 
    <f:else> 
 
     <f:comment>init variables</f:comment> 
 
     <v:variable.set name="lastitem" value="{item}" /> 
 
     <v:variable.set name="counter" value="1" /> 
 
    </f:else> 
 
    </f:if> 
 
</f:for> 
 
<f:if condition="{lastitem}"> 
 
    <f:comment>output last item, if any</f:comment> 
 
    <f:render partial="showItem" arguments="{item:lastitem, counter:counter}" /> 
 
</f:if>

関連する問題