We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Looping through collection based on custom date

Peter Emil van den Berg January 17, 2018 by Peter Emil van den Berg

I'm working on a collection which is a list of theater-productions.

Every production can have multiple dates when its performed. This date is being used to sort all productions in their own list and in one combined list. This combined list gives me troubles; when it's rendered it shows the productions alphabetical first and within their instances descending in date. To clarify this is what it looks like now:

Dido Dido – 2018-02-20
Mask Off – 2018-01-10
Mask Off – 2017-10-10
True Colors – 2018-02-01
True Colors – 2018-01-01
True Colors – 2017-08-01

But the intention is that the list flows like this:

Dido Dido – 2018-02-20
True Colors – 2018-02-01
Mask Off – 2018-01-10
True Colors – 2018-01-01
Mask Off – 2017-10-10
True Colors – 2017-08-01

So the date has to be prevalent.

How can I sort the combined list based on date alone?

The fieldset productions.yaml looks like this:

title: Productions
hide: true
taxonomies: false
    type: title
    type: replicator
            type: date

The template productions.html looks like this:

{{ collection:productions sort="playdate:desc" }}
  {{ performances sort="playdate:desc" }}
      <li>{{ title }} – {{ playdate }}</li>
  {{ /performances }}
{{ /collection:productions }}
Answered by Jason Varga!
>>>>>>> Answered <<<<<<<
14 Replies