简体   繁体   中英

TYPO3 (6.2) and extbase: add items to QueryResult

I have a list of events and what I need is show the first 5 events of a certain category on page 1 and then show all events (including the first 5 of category X) on the next pages.

So what I tried to do is create 2 extbase Queries for my results and tried to merge those 2. But with toArray or ObjectStorage I get something like the following error in my pagination template:

Argument 1 passed to TYPO3\\CMS\\Fluid\\ViewHelpers\\Widget\\PaginateViewHelper::render() must implement interface TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface, instance of TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage given

so how can I merge 2 QueryResults without converting them to something else? Or is there another way to achieve what I need to achieve?

A little example of how I need this:

page 1 (the first 5 Events in Category X): 
    Event 4, Category X
    Event 5, Category X
    Event 8, Category X 
    Event 9, Category X
    Event 10, Category X 
page 2 (from now on everything is sorted by ID): 
    Event 1, Category A
    Event 2, Category B
    Event 3, Category B
    Event 4, Category X
    Evnet 5, Category X
page 3: 
    Event 6, Category A
    Event 7, Category B
    Event 8, Category X
    Event 9, Category X
    Event 10, Category X

using f:widget.paginate in my template.

First off, the concept of pagination does not really apply here when moving from page 1 to page 2. What would the user expect? Certainly not recurring results?

More to the point: only as of TYPO3 7.6 does the PaginationViewHelper support arrays in addition to QueryResults. But there is a backport floating around (I have used it with 6.2).

To solve your problem, why not use separate queries with separate pages as your content elements seem to have semantically different purpose? When using a custom WidgetController you could adjust the QueryResult to your purpose on arbitrary conditions like a certain page (this is what it is designed to do), if you really must, but I would advise against it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM