Dates in page.collection()

Is it possible already in Grav core to generate a collection using something like pull all posts after 01/01/2015?

Currently no, but as it happens i’m working on some collection refactoring today, so i’ll take a look and see if this is easily doable.

Ok, I’ve added this and it will be in the next release which will be out very shortly.

Basically you can use it two ways. You can add a dateRange to a collection definition in the page headers:

content:
    items: @self.children
    order:
        by: date
        dir: desc
    limit: 5
    pagination: true
    dateRange:
        start: 1/1/2014
//        end: 1/1/2015

End date is optional and is commented out here. Also you can use 'human readable dates that are supported by PHP’s strtotime(). So you could set a date to be something like start: "-6 months" to filter the pages for last 6 months only.

The other option is to act directly on the collection using similar syntax. For example:

{% for p in page.find('/blog').children.dateRange('01/01/2014', '01/01/2015').order('date', 'desc') %}

As you can see this is pretty powerful, but I’ve also added modular(), nonModular(), nonVisible(), nonRoutable() and also published(), nonPublished() methods to Collection object. All of these are chainable, so you can really get some sophisticated results now.

Just need to document all these cool methods that will be available in Grav v0.9.13 :slight_smile:

AWESOME

I think this is exactly what is needed to do events sort of stuff in Grav.