Files list of existing files with the ability to exclude unwanted items


Im trying to find a way to have a files field which would list all existing files within a pages folder. Similar to how the files filed in a page preset behaves, but with the ability to exclude unwanted files.

Files field

        type: files
        query: page.files.not(page.header.toFile)

Using files field doesn’t show existing files within the folder. Files can be selected or uploaded, but that’s not what im aiming for.

Apart of that, newly uploaded files from textarea do not show up in that field.

Files preset

    preset: files
    query: page.files.not(page.header.toFile)

Behaves exactly like files filed. Neither existing files nor newly uploaded files from textarea show up here.

Files section

Using files section seem not a right way either, since it doesn’t support querying

Page preset

title: Page
preset: page
pages: false
    label: Content
    type: textarea
    type: fields
        label: Publish Date
        type: date
        label: Header Image
        type: files
        multiple: false
        query: page.images
        layout: cards
          cover: true
    query: page.files.not(page.header.toFile)

The files field works as expected. All existing files are shown and uploaded files from texarea are showing up in the list, however I can not filter the list in order to exclude unwanted items :confused:


What is the way to have a list of files behaving as the files in page preset with the ability to filter the shown items?

Thank you in advance.

Kind regards

A files field is basically a (multi)select field for files, there is no way this field would display all existing files automatically.

Therefore, a files section would actually be the right approach, and you would add assign a (differnt) template at upload to filter them from other files you use in the page that you assign different templates to.

That would also enable you to query those files by template in the frontend.

There is also the files display section plugin which would allow you to query files (but then not upload to this section):

This sound interesting, but unfortunately I can’t find anything on the topic.

Could you point me to how to assign a template when uploading a file from textarea and files section please.

Files section: Files section | Kirby CMS
Files field: Files | Kirby CMS
Textarea: Textarea | Kirby CMS

1 Like

Thank you!