I feel this should be simple, but I can’t make it work. In my Simple Events plugin, I would like to add the option to automatically remove past events. To this intent, I need a collection of pages of the
Event type in PHP, so that I can then check the date of each page and delete it if it’s in the past.
I have tried a few things:
$collection = new Collection(); $collection->ofType('event')->order('header.start', 'asc');
returns an empty array.
$ev = $collection->ofType('event')->dateRange('01/01/1970', 'today');
empty as well.
$ev = $collection->setParams(['items' => '@root.descendants'])->ofType('event')->dateRange('01/01/1970', 'today');
Seems to me like I’m not telling PHP to get me all pages in the right way, so all the filtering afterwards sifts through emptiness.
$pages = Grav::instance()['pages']->all();
returns all pages, which is nice and I will use that and iterate over it if I have to… but it seems to me there should be a simpler way? Can somebody help me out here?
Thanks for reading!