Hi,
I’ve got a files section and want to show it only, when a files-field has some content.
My use case is:
I have an image gallery (files-preset ‘default’).
For that gallery I want to provide a cover via a cover field (max: 1).
In that cover field the editor can either select one of the uploaded gallery images (files-preset ‘default’),
or upload a cover-file with a files-preset ‘page-cover’.
The problem is, if the user will later deselect the uploaded cover-file from the cover-field,
the uploaded file will remain in the content folder but the user can not delete the file itself,
because the images section (see left column in blueprint below) shows only the ‘default’-templates.
That’s why I have set up an extra files-section to give an option to delete the file,
but I also don’t want the editor to be able to upload a file via the files-section (he already has that option in the cover-field)…
So, this files-section shows only images with the ‘page-cover’ template.
And since it’s not possible to set a max of 0 to a files section,
I only want to show it, when a cover has been uploaded via the cover-field.
I know, it’s a bit confusing, but I didn’t know, how to explain it less complicated… sorry for that.
Is this possible with just a blueprint setup?
Or maybe a hook?
columns:
# ––––– LEFT PAGE COLUMN –––––
left:
width: 2/3
sections:
images:
type: files
headline: Bilder
layout: cards
template: default
info: "{{ file.dimensions }} px"
text: "{{ file.title.or(file.filename) }}"
image:
ratio: 4/3
cover: true
min: 1
size: small
# ––––– RIGHT PAGE COLUMN –––––
right:
width: 1/3
sections:
pageInfo:
type: fields
fields:
cover:
label: Titelbild
type: files
layout: cards
uploads: page-cover
max: 1
size: small
#query: page.images.filterBy('template', 'page-cover')
coverFiles:
type: files
headline: Alternative Titelbilder
template: page-cover
max: 1 #<<max: 0 not possible
when:
cover: "{{ page.cover.isNotEmpty }}" #<< sth like that?