Pagination by next dates and old dates last

I display in a collection a sort by higher date (all the articles higher than today must be displayed).

Everything is working.

return function () {
    return page()
        ->children()
        ->listed()
        ->filterBy('datesejour_start', 'date >=', 'today')
        ->sortBy('datesejour_start', 'asc');
};

I would like to display the exceeded dates at the very end of the list (So that I can see them in the pagination).

I would put on a red color badge.

 ->filterBy('datesejour_start', 'date <=', 'today')

I don’t understand what your question is.
You said everything is working.
What do you need help with then?

If you filter your list by date, then all dates prior to that will of course not be in the list.

So you can create a second list with dates prior to today, and then handle that separately. Or you keep everything in your list and then check the date while looping.

Hello,

what I had done was actually create 2 independent lists in my template, but the problem is that the pagination bug.

Is it possible to manage this upstream? do i have to do it in controller with 2 conditions?

and then switch to paging?

is there an example?

I’m still not entirely sure what you’re trying to achieve here but I suspect is something somewhat similar to what i’m doing on my site. I display the posts of the current month separately from all the other posts. You want future posts and then old posts with a different style.

And then pagination is involved if i’m not mistaken.
If everything is displayed in one list I don’t see why you want to loop through two lists.

You can simply sort by date and then check if each item has a date that is in the past or in the future and assign a css class to change the style.

If for some reason you want to have a list of future items always visible AND old items in a separate list I think the best solution is to make two collections. This way you have two independent sets you can work with.

Can you post a screenshot of what you’re trying to achieve? Because not sure about you @texnixe but i’m still somewhat confused about what we’re trying to make here

Right.

So please try to explain in simple words what exactly you want to achieve.

Hello manuelmoreale

It is indeed the 2nd solution.

I display upcoming events (current dates and future dates) in cards. I would then like to display other cards with the dates exceeded.

I would actually change the display with a different style.

Everything must be in the pagination.

Indeed I will create 2 collections.

I’m thinking of calling these 2 collections in the controller, one after the other. And pass in the pagination.

When you say pagination you mean that you have the classic newer events / older events buttons? And if that’s the case, when someone clicks on older events, do the events in the future have to stay visible somehwere in the page?

Because if they don’t have to stay visible in each page of the pagination, then you don’t even need two collections. You can simply use a simple collection paginated and as I mentioned in my previous post, check on each items if the date is in the future/past and change the style.