I have a collection of pages (that serve as project entries) which I can sort manually in the panel. On the homepage I would like to list them in the same order. However, they are getting sorted in a way a can’t fathom. Any help would be much appreciated!
The Page Blueprint Projects
title: Projects
sections:
projects:
type: pages
info: "{{ page.date }}"
sortable: true
layout: cards
image:
ratio: 4/6
cover: true
template: project
The Page Blueprint for a single project
Not sure if this is relevant.
I have tried to set num: true
in this blueprint. This resulted in the loss of the drag & drop functionality in the pabel.
title: Project
columns:
- width: 1/2
sections:
info:
type: fields
fields:
date:
label: Date
type: text
photocredits:
label: Photography Credits (optional)
type: text
- width: 1/2
sections:
previewimg:
label: Preview Image for Homepage (optional)
type: files
template: previewimg
layout: list
sortable: false
max: 1
projecttexts:
label: Project Texts (PDF)
template: projecttexts
type: files
layout: list
sortable: true
empty: No documents yet
projectimages:
label: Project Images (JPG, PNG, GIF)
info: "{{ file.caption }}"
template: projectimages
type: files
layout: cards
empty: No images yet
sortable: true
image:
ratio: 1/1
The Controller «home»
<?php
return function ($site, $page) {
// data for the template
return array(
'projects' => page('projects')->children()->listed()->sortBy('sort'),
);
};
I was hoping to get same order I created manually in the panel by applying sortBy('sort')
as mentioned in the documentation relating to the sorting of files. However, I get a totally different order I can’t figure out.
I am not sure if I messed up in the blueprints or in the way I query the projects.
Version etc.
- Kirby 4.7.2
- php 8.3
- ddev environment