Files section with query and uploads template

I’m trying to do the same thing as I see in the docs right here: https://getkirby.com/docs/reference/panel/sections/files#filtering-files__query

So basically I want to have a files section, that uses a query to display files with varying templates, but still with a template set for uploads.

In the linked docs example the uploads option is used to set the template together with a query just like what I want to do. I can’t get that to work. When uploading a file it doesn’t get assigned a template. (If I instead set the template option it will also filter the query by that template, which is not desired in this case.)

I see that the uploads prop is not in the properties list. Can someone verify if this is supposed to work or no? Perhaps the docs example is a mix-up with the files field (which does have the uploads option)? Either way, I think this is a needed feature since queries was introduced in 4.0. It would also align the setup of the files section and files field.

pageImages:
    label: "All uploaded images"
    help: The table above shows both **used** *and* **unused** images
    type: files
    query: page.images # just an example 
    uploads: image # This does not get applied on uploads
    # template: image # <-- `template` also filters the list which I do not want
    empty: Add some images
    search: true
    layout: table
    rawvalues: true
    image:
      back: pattern
      cover: false
    columns:
      title:
        label: Filename
      alt: true
      photographer: true
      crop:
        label: Crop/focus
        value: "{{ file.panelImgInfo(false) }}"
      orientation:
        label: Format
        align: right
        value: "{{ file.orientation }}"
      dimensions:
        align: right
        value: "{{ file.dimensions }}"
      size:
        align: right
        value: "{{ file.niceSize }}"

unusedImages:
   # another similiar section here querying a custom page method

I think it’s a bug/documentation error indeed.

Given the current implementation, I think the easiest would be to still use the template option to define the upload template, but don’t filter the displayed files further when already a query is defined. But maybe your point on consistencies between field and section is more important.

Opened an issue: Files section: allow defining upload template, when `query` · Issue #6707 · getkirby/kirby · GitHub

Thanks for confirming and opening an issue @distantnative !

Here’s some input…

When I think about it, your suggestion to change the way the template option works when a query is set is indeed clean and makes sense. That way you are not introducing an additional prop just for this nuance.

(One thing to consider perhaps is if that would be a breaking change as eixisting code would have to adopt their existing queries. If you have used a query + template to filter, you would need to adjust your query to also do the filtering.)

Would you instead add the upload prop I would expect to be able to use it also without a query, with or without template set. I guess you will need to think about each use case and scenario.