Using blog as agenda

I need some help here: I intend to use the regular blog item within a Quark heritage as an agenda. Thing is, there are agenda items to come, and agenda items in the past. My question is how I can possibly modify the order of these items. To explain, let’s image monthly agenda events. The agenda/blog page looks like this:

February 2020 : Making Sushi
March 2020 : Making Pizza
April 2020 : Making Pasta
“Too late” [(an undated agenda item)]
January 2020 : Making Salad
December 2019 : Making Rice
November 2019 : Making Bread

So essentially I have two item orders, one asc, one desc. And once an event is over, it needs to go down below the “Too Late”.

Any ideas how this can be done ? I don’t mind moving past items if that doesn’t mean I have to touch all items.

Thanks !

@Andrass, You might want to have a look at the docs on Complex Collections and Collection Object Methods.

You could, for example, create 2 collections using the filter Collection::dateRange($startDate, $endDate, $field) and sort them differently.

Of course, in Grav there are more road leading to Rome…

Thanks @pamtbaau, I was almost (?) done when it occured to me that manual sorting is perfectly fine for my needs. So case closed.

But let me look a little deeper into my “almost” solution. For this I created 2 customs fields : One called “active” that when > 0 means the event is upcoming. Sorting by upcoming brings those into the right order. The other field “endDate” is used for sorting past events.

What didn’t work was to sort the agenda-items by two criteria:

title: agenda
    items: '@self.children'
        dir: desc
        by: header.agenda.endDate
        dir: asc
    limit: 10
    pagination: true

Les actualités et dates à retenir

I searched the docs, but wasn’t able to find whether I can have more than one sort criteria.

Any info on this ?

Thanks again!


The Collection:order() function does not seem to provide for a nested ‘by’…

Collection extends Iterator, which has a method sort(\callable $callback=null, bool $desc=false): \Grav\Common\$this/array.

The $callback function can then sort on any Page property you like. I guess…

Don’t think you can use this in the page header, but maybe in Twig.

1 Like

Thanks for looking into this, much appreciated!