2016-11-29 4 views
0

私は現在のニュース項目の中から次のニュース項目を取得しようとしています。 拡張子「vhs」およびtx_newsを使用しています。Vhs-viewhelperとforループ

{namespace v=FluidTYPO3\Vhs\ViewHelpers} 
<f:for each="{news}" as="newsItem" iteration="iterator"> 
    Current title: {newsItem.title} 
    <v:variable.set name="nextNews" value="{v:iterator.next(needle: newsItem, haystack: news)}"/> 
    Next title: {nextNews.title} 
</f:for> 

正しいタイトルを一度印刷します。その後、ループは突然終了します。

答えて

0

これ以上の「次の」ニュースがないため、最後の反復に追いつくための条件を設定しようとします。

{namespace v=FluidTYPO3\Vhs\ViewHelpers} 
<f:for each="{news}" as="newsItem" iteration="iterator"> 
    Current title: {newsItem.title} 
    <f:if condition="{iterator.isLast}"> 
    <f:else> 
     <v:variable.set name="nextNews" value="{v:iterator.next(needle: newsItem, haystack: news)}"/> 
     Next title: {nextNews.title} 
    </f:else> 
    </f:if> 
</f:for> 
+0

それを試してみましたが、変更はありません。 – johndoe33

+0

エラーの表示を有効にして、インストールツールのdevIpMaskにあなたのipを設定してみてください。何の誤りもなく、私たちは何ができるのかしか推測できません。 –

0

私は昨日、forループの変数を設定する際に問題がありました。 私はその変数をクリアすることで問題を解決しました。 あなたのケースでは、私は次のことをしようとするだろう:

{namespace v=FluidTYPO3\Vhs\ViewHelpers} 
<f:for each="{news}" as="newsItem" iteration="iterator"> 
<v:variable.set name="nextNews" value="" /> 
Current title: {newsItem.title} 
<v:variable.set name="nextNews" value="{v:iterator.next(needle: newsItem, haystack: news)}"/> 
Next title: {nextNews.title} 
</f:for> 

1は(再び)それを設定する前に、変数をクリアしますこと。 少なくとも私はそれを試してみるでしょう:)