Hi,
I am trying to create a section in a blueprint where image files appear that were “selected” and alow them to be sortable to create a curated gallery.
The setup
- A parent called paintings with several child pages for each year.
- Every year contains image files of painting in that year.
- Each painting has a txt file with several data fields, one of which is a toggle field.
- The toggle field allows you to selects the painting to show in the curated selection.
Blueprint for year:
Title: Year
sections:
files:
headline: Paintings
type: files
template: painting
sortable: true
The aim
Display these selected paintings on the paintings blueprint so that they can be sorted manually.
selected_artwork:
type: filesdisplay
query: site.index.files.template("painting").filterBy('selected', true)
Things I have tried
01 The FilesDisplay Section plugin.
Works a treat, but you can’t manually sort the files - as it says in the description of the plugin.
Is there a reason why the sorting is not possible? The manual sorting is crucial for my client.
02 A collection
In collections/paintings.php
return function ($site) {
return $site
->find('paintings')
->children()
->images()
->template('painting')
->filterBy('selected', true);
};
In blueprint
selected_artwork:
type: files
query: kirby.collection('paintings')
sortable: true
The collection gets the correct files, but nothing shows up in the blueprint. Unless I change the type to radio, and then they do show up. But I don’t want radio buttons.
03 A structured field on the year pages
Title: Year
fields:
paintings:
label: Paintings
type: structure
fields:
artwork_title:
label: Title
type: text
artwork_image:
label: Image
type: files
selected:
label: Display in Selected Works?
type: toggle
text: ['No', 'Yes']
This makes it easy to toggle paintings on or off, but I have no idea how to pick an item from a structured field.
So, if anyone has ideas. I am all ears.
Thank you.