1

I am having trouble referencing specific subfolders in Assets in Craft 3 using Twig. The query that I've written is still showing all content, when I only want it to show content from a specific subfolder.

The folder layout: /files/asset-volume/subfolder/file.txt

When I try this query code, I still get all of the files from the volume, when I only want the subfolder. How do I only reference the specific subfolder?

{% set subFolders = craft.assets()
                    .volume('asset-volume')
                    .includeSubfolders('subfolder')
                    .all()
%}

1 Answer 1

1

Have a look at the folderId parameter. https://docs.craftcms.com/v3/dev/element-queries/asset-queries.html#parameters

To find which id your folder has, it looks like you have to look in the assets table - someone might have an easier solution.

1
  • 1
    Yeah, I looked at the folderId parameter, but to get that to work with what I'm doing I'd have to do some finagling. I did something similar with jQuery. Jan 21, 2020 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.