Hi, I’m following the Cookbook for automatically grouping sub pages into sections:
I’m trying to use this on my home page, which has child pages (“Werke”, Template “Werk”) that are grouped by tag. That part is working nicely.
However I can’t seem to get manual sorting to work, I really like the standard drag and drop functionality with pages sections, but for some reason the sort-icon doesn’t show up & the “change position” option in the context-menu is disabled. I do however get the “Position” Option when clicking “change status”.
My blueprints for parent and child page don’t include the “num: zero”, which typically disables manual sorting, so I’m banging my head against my screen, metaphorically speaking.
my home_blueprint.php
<?php
$content_section = [
'content' => [
'type' => 'fields',
'fields' => [
'pagetitle' => [
'label' => 'Seitentitel (SEO)',
'type' => 'text',
'width' => '1/2',
'help' => 'Google Suchergebnis-Titel. Max. 60 Zeichen empfohlen'
],
'pagedesc' => [
'label' => 'Seitenbeschreibung',
'type' => 'text',
'width' => '1/2',
'help' => 'Google Suchergebnis-Beschreibung. Zw. 150-160 Zeichen empfohlen'
]
]
],
'drafts' => [
'extends' => 'sections/werke',
'label' => 'Werke (EntwĂĽrfe)',
'status' => 'draft'
]
];
$tag_sections = [];
if ($page = page('home')) {
// create a new section array for each unique tag plucked from the children pages
foreach ($page->children()->pluck('tags', ',', true) as $tag) {
$tag_sections['section_' . $tag] = [
'type' => 'pagesdisplay', //provided by plugin
'label' => 'Werke ' . $tag . ' (Veröffentlicht)',
'status' => 'listed',
'parent' => 'kirby.page("home")',
'size' => 'small',
'info' => '"{{ page.images.count }} Bild(er), Tagged: {{ page.tags }}"',
'layout' => 'cards',
'template' => 'werk',
'empty' => 'Keine Werke hier',
'image' => [
'query' => 'page.cover',
'cover' => 'true',
'ratio' => '5/4'
],
// note the required quotes around the `$tag` variable
'query' => "page.children.filterBy('tags', '". $tag . "', ',')",
];
};
//Sort tags by key, desc
krsort($tag_sections);
}
// create the array for the page blueprint with two columns
$yaml = [
'title' => 'Home',
'icon' => '🏠',
'options' => [
'changeStatus' => false
],
'sections' => array_merge($content_section, $tag_sections)
];
return $yaml;
my werk.yml blueprint
title: Werk
icon: đź–Ľ
status:
draft: true
listed: true
#Disable Manual Sorting
#num: zero
columns:
- width: 1/3
fields:
cover: fields/cover
layoutwidth:
label: Breite im Layout
type: range
step: 50
min: 250
max: 600
default: 400
tooltip:
after: px
headline:
label: Titel
type: text
placeholder: "{{ page.title }}"
beschriftung:
label: Beschriftung
type: text
placeholder: 300 cm x 200 cm, Blood and Sweat on Canvas
tags: true
label: Tags (Jahr)
- width: 2/3
sections:
images:
label: Bilder
type: files
layout: cards
template: image
info: "{{ file.dimensions }}"
image:
ratio: 5/4
cover: true
min: 1
size: small