Skip to content

Instantly share code, notes, and snippets.

@bartwttewaall
Created January 14, 2022 09:04
Show Gist options
  • Save bartwttewaall/3e76498bf10de5254974698955363b87 to your computer and use it in GitHub Desktop.
Save bartwttewaall/3e76498bf10de5254974698955363b87 to your computer and use it in GitHub Desktop.
Order by two different conditions, but with a joined result in order to be able to use pagination
{% set currentDay = date(now)|date('Y-m-d') %}
{% set comingQuery = craft.entries.section('agenda')
.geplandeDatum(['and', '>= '~currentDay])
.orderBy('geplandeDatum ASC')
.ids()
%}
{% set pastQuery = craft.entries.section('agenda')
.geplandeDatum(['and', '<'~currentDay])
.orderBy('geplandeDatum DESC')
.ids()
%}
{% set ids = comingQuery|merge(pastQuery) %}
{% set query = craft.entries.id( ids ).fixedOrder(true) %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment