Paginate future-dated pages

I’m trying to do something similar, and query for events which are in the future (so, not displaying events which are in the past).

I was going to try the approach of using a paginator, and have an if statement within the range, but this wouldn’t work, as it would potentially show blanks in certain pages and create an inconsistent experience. Consider that you have 2 events, one in the past, and one in the future. For arguments sake, you have display 1 result per page. You would then have 1 blank page, and 1 populated page…

I’m looking for someting like this -

{{ $futureEvents := where $currentSection.Pages (time .Params.eventDate) “>=” now}}
{{ paginator := .Paginate $futureEvents }}

Is something similar possible? I’ve been looking through the docs, and the community posts, but can’t seem to piece together a scenario that would fit.

Hi there,

I’ve moved your question into its own topic as the one you were replying to is 2 years old and has been marked anwered.

Edit to add:

I’m not entirely sure I understand what you are trying to achieve?

{{ $future := where $pages ".Params.eventdate" "ge" (now.Format "2006-01-02") }}

future pages: [{{ $future }}]

{{ $paginator := .Paginate $future }}

{{ range $paginator.Pages }}
  {{ . }}
{{ end }}

No problem! And thanks for getting back to me :slight_smile: For completeness for anyone reading back, I’m trying to make a view, where I have a list of events that are in the future. I’ll then have a separate page for past events.

The magic piece of the puzzle is the (now.Format …) piece that you have included. Previously I was trying all sorts of combinations, e.g. just using now directly, using now.Unix, etc.

Thanks again for this, I went over so many combinations I think I was starting to get myself a little confused :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.