Karsten
Karsten

Reputation: 15

TYPO3 Fluid items -> f:count() select field and f:widget.paginate

I currently have the following problem:

An item has different variables that I select simple via a select in the TCA. Now with my pagination widget I want to select only the elements that have this variable 1.

Of course, if I set a condition within the pagination, it does not work, because it calculates these into these pages (which suggests more pages than actually exists).

<f:if condition="{items -> f:count()} > 1">
 <f:then>
     <f:widget.paginate objects="{items}" as="paginatedItems" configuration="{itemsPerPage: 10, insertAbove: 0, insertBelow: 0, maximumNumberOfLinks: 10}">
         <f:for each="{paginatedItems}" as="item">
             <f:if condition="{item.variable} == 1">
                <div>.....</div>
            </if>
        </f:for>
    </f:widget.paginate>
</f:then>
<f:else>

Upvotes: 1

Views: 1233

Answers (1)

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10800

You need to compute the pagination on the subselection in that way that you need to eliminate all unwanted records before you give the array of items to the pagination viewhelper.

  • Either you get this subselection directly from the repository (create a new query)
  • or you subselect the array of items into another fluid variable like it is done by ext:news (evaluation of already shown records)

I would prefer the first solution if possible as the performance should be better and it's scalable too.

Upvotes: 2

Related Questions