Adding a descending argument to custom field num: '{{ page.year }}'

I’ve gotten my items to be organized by the custom year field, but I was wondering if I could reverse their order? They are currently organized in an ascending manner, and i would like it to be descending.

I tried

num: ‘{{ page.year, ‘desc’ }}’

And it didn’t work. I don’t see any syntax suggested for this in the documentation, any ideas for this?

Thx in advance

Here documentation:

I guess, you need custom page method like that: page.yearFlip

I see, I thought that since the method outputs an integer it would be possible to pass a second parameter to change the order. I’ll try adding another method that outputs the right one.

The numbering scheme doesn’t influence the order in which the pages appear in a pages section.

For that you can use the sortBy option: https://getkirby.com/docs/reference/panel/sections/pages#sorting

e.g.

sortBy: year desc

Just going back to this issue.
I was able to get it to work with your answer @textnixe :+1:

I also figured out that sortyBy takes multiple parameters, because after doing

sortBy: year desc

I was getting the right order, but it overode the status of the projects (draft, unlisted or public). So I did

sortBy: status desc year desc

And it kept the status first for sorting and the year second. Didn’t see this option on the documentation, but it’s great how flexible it is.

I modified the pages section docs to reflect this. It’s mentioned here $pages->sortBy() | Kirby CMS, and the methods usually work in more or less the same way in the panel, but that’s certainly not obvious, especially not for people new to Kirby.

1 Like