Hi,
I use the option “sortBy” to sort pages in a panel section. The “sortBy” option works to sort the pages but the prev/next button seems not to consider the “sortBy”.
I made a test on the starter-kit. I added a “questionId” in “Notes” txt files and sort the notes pages on this “questionId”.
notes.yml
type: pages
headline: Notes
parent: kirby.page("notes")
info: "{{ page.questionId }}"
template: note
empty: No notes yet
sortBy: questionId asc
You can download the code here:
https://transfernow.net/11kzn2l2yo9w
I know more situations in Kirby 3 panel, where the prev/next buttons do not work like I need, e.g. if they have different blueprints.
texnixe
September 9, 2019, 7:50pm
3
Looking at the source code, sorting is ignored
'next' => function (Page $page) {
return $page
->nextAll()
->filterBy('intendedTemplate', $page->intendedTemplate())
->filterBy('status', $page->status())
->filterBy('isReadable', true)
->first();
}
public function nextAll()
{
return $this->siblingsCollection()->slice($this->indexOf() + 1);
}
protected function siblingsCollection()
{
if ($this->isDraft() === true) {
return $this->parentModel()->drafts();
} else {
return $this->parentModel()->children();
}
}
texnixe
September 9, 2019, 7:56pm
4
You could create a custom section…
You mean as we do with a page models?
Could you show me how to start, I’m not sure to understand
texnixe
September 10, 2019, 12:55pm
6
No, I mean a custom pages section plugin: Sections | Kirby CMS
You can reuse the existing pages section, and add sorting of pages to it. Here is an example plugin that extends the pages section: GitHub - rasteiner/k3-pagesdisplay-section: K3 plugin: display any page list in a section. Any parent, many parents, filtered, don't care.
Of course, you can additionally create a feature request in the ideas repo.
Amazing, another new Kirby trick I didn’t know
I will take a look at it later …
Thanks Sonja