I just migrated one of my old sites to Grav 2 (went without a hitch, I love the migration wizard). However, there’s a news page which orders its children by page date descending.
This is the code that used to work:
{% set collection = page.collection({'items':{'@self.children': ''},'order': {'by': 'date', 'dir': 'desc'}}) %}
{% for p in collection %}
(output other details)
{{ p.date|date("d.m.Y") }}
{% endfor %}
What happens now is that every date is output as today’s. I did some dumps:
{{ vardump(collection) }} shows the timestamp of this morning, 11:30, which is the time I downloaded all the content from the live version to tinker with.
It seems to me that maybe page.date has always referred to the file’s creation date, and not page.header.date – but nobody noticed before because that was usually the same thing. Can someone confirm that’s how it’s meant to be?
That would mean that I cannot sort by page.date if I want to refer to page.header.date, but also sorting by page.header.date sorts alphanumerically, which is not what I want either. What is the best solution here?