getkirby / ideas

This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
https://feedback.getkirby.com
20 stars 0 forks source link

Separate upload- and template options in files section #597

Open cgundermann opened 4 years ago

cgundermann commented 4 years ago

Files section, according to the Docs: property: template, Description: Filters all files by template and also sets the template, which will be used for all uploads

Here's an example of a files field with the following select & upload options:

fields:
  cover:
    type: files
    query: page.images
    uploads:
      template: cover

and a files section on the same page:

sections:
  images:
    type: files

this section displays all files of the page, allowing me to edit / delete individual files with any template (incl. cover),
but when uploading via this section, no template will be assigned to the file.
Now the following setting

sections:
  images:
    type: files
    template: default

will assign a default template to the uploaded file, but won't display files with other templates assigned, which makes it impossible to edit / delete a file with the template cover from this section. I would need an extra files section for that.


I think, a files section with separate template and upload options (similar to a files field) could avoid having unnecessary extra files sections just for the purpose of editing / deleting files with various assigned templates.

sections:
  images:
    type: files
    uploads: default # define a template to be assigned on upload
    template: # optional (default shows all files with any template)
      - default
      - someothertemplate

Or did I miss a solution to my problem? 🤔

texnixe commented 4 years ago

If you need a workaround for the time being, you could assign a template to the files via a file.upload.after hook.

cgundermann commented 4 years ago

Thanks for the suggestion, @texnixe, this means, on the frontend, I can't filter by the template anymore, if I wanted to skip the cover file, right?

foreach($page->files()->filterBy('template', 'default') as $file):
...

I would have to add an additional field in the file blueprint:

# files/cover
extraFilterField:  cover
# files/default
extraFilterField:  default

and then on the frontend:

foreach($page->files()->filterBy('extraFilterField', 'default') as $file):
...