Hello,
I am writing a custom pages sorting method:
<?php
Kirby::plugin('jaume/pagesMethods', [
'pagesMethods' => [
'sortBySurname' => function () {
return $this->sortBy(function ($child) {
// xplode
$words = explode(' ', $child->title());
// take maximum two words
$words = array_slice($words, 0, 2);
// obtain the last one
$last_word = array_pop($words);
// use it to sort
return $last_word;
}, 'asc');
}
]
]);
This seems to work on the fronted, using it like this, as it returns the sorted collection.
$page->children()->sortBySurname()
But I also want to use it on a pages section in the panel, and it does not seem to work there, I tried:
sections:
artists:
type: pages
sortBy: page.children.sortBySurname
and also
sections:
artists:
type: pages
sortBy: sortBySurname
But it does not seem to sort as in the frontend, so I assume it is not working at all, but it does not throw any exception.
Thank you