<p>Writing a plugin would be your best shot. You can use AssetsService to get all the information you need (<a href="http://buildwithcraft.com/classreference/services/AssetsService" rel="nofollow">http://buildwithcraft.com/classreference/services/AssetsService</a>)</p>

<p>This might change with a future release, but the need to query Assets folders directly from a template is so rare, that I'm not entirely convinced it will make it's way into a future release at this point.</p>

CC BY-SA 3.0
2014-10-07T11:19:03.983Z
Thanks Andris for giving a proper answer. I probably disagree with you that there's only rare use cases for this. Uploading assets on a batch to create entries could be a convenient way to add content. Think photographers etc.! Would it be possible to also read metadata from the files and write those into asset fields. This would allow to edit your project (portfolio etc.) in an external app like adobe lightroom. :)
carlcs
CC BY-SA 3.0
2014-10-07T18:24:46.087Z
Yeah, calling it "so rare" was probably an overkill. I'm still leaning towards the plugin route, though, since the methods are all there in the service and AssetFolderModels already have methods for traversing the tree.  


As for the metadata - it's on the list, but that will most likely require Imagick installed.
Andris Sevcenko
CC BY-SA 4.0
2024-03-15T11:29:52.907Z
Old link - but a dead one.
Keith John Hutchison
CC BY-SA 3.0
2014-10-07T10:27:06.047Z
2014-10-07T10:27:06.047Z
Andris Sevcenko
<p>I'm building a customer portal for work, and we are storing customer-facing files on the site in an Amazon S3 bucket. I currently have it all set up as a Structure section with an Asset field. I query for each entry using its uri, and for Folder Entry Types I pull and output its children.</p>

<p>My hope is that I can instead query for Asset folders and files directly, and then add a few fields to Assets (through the usual methods). Querying for files is fine, but I can't see any variables to pull folders. Would I need to write a plugin for this?</p>

CC BY-SA 3.0
2014-08-28T14:49:57.633Z
There's no function for this (yet?), but you could try fetching them over `craft.assets` and `asset.getFolder` and build your custom asset folder object with Twig :D
carlcs
CC BY-SA 3.0
2014-09-28T22:49:11.903Z
Went to answer this, @carlcs, but realized I was going to type exactly what was in your comment.  Want to add it as an answer?
Brad Bell
CC BY-SA 3.0
2014-10-06T17:27:39.080Z
@Brad I'm not sure this is a working solution, that's why I wrote "try". Yes, this is rather easy if you don't nest folders. But if you do, you need to reconstruct the assets' complete folder structure with `asset.getFolder`, `parent` and `id`.
carlcs
<assets>
How do you query for Asset Folders?
# How do you query for Asset Folders?

(Asked by: username_0 on 2014-08-28)

I'm building a customer portal for work, and we are storing customer-facing files on the site in an Amazon S3 bucket. I currently have it all set up as a Structure section with an Asset field. I query for each entry using its uri, and for Folder Entry Types I pull and output its children.

My hope is that I can instead query for Asset folders and files directly, and then add a few fields to Assets (through the usual methods). Querying for files is fine, but I can't see any variables to pull folders. Would I need to write a plugin for this?

**Tags:** assets

> **Comments:**
> **username_1**: There's no function for this (yet?), but you could try fetching them over `craft.assets` and `asset.getFolder` and build your custom asset folder object with Twig :D  
> **username_2**: Went to answer this, @username_1, but realized I was going to type exactly what was in your comment.  Want to add it as an answer?  
> **username_1**: @Brad I'm not sure this is a working solution, that's why I wrote "try". Yes, this is rather easy if you don't nest folders. But if you do, you need to reconstruct the assets' complete folder structure with `asset.getFolder`, `parent` and `id`.  

---

## 1 answers

### Answer by username_3 on 2014-10-07. Score: 3 | Accepted answer

Writing a plugin would be your best shot. You can use AssetsService to get all the information you need (<http://buildwithcraft.com/classreference/services/AssetsService>)

This might change with a future release, but the need to query Assets folders directly from a template is so rare, that I'm not entirely convinced it will make it's way into a future release at this point.

> **Comments:**
> **username_1**: Thanks Andris for giving a proper answer. I probably disagree with you that there's only rare use cases for this. Uploading assets on a batch to create entries could be a convenient way to add content. Think photographers etc.! Would it be possible to also read metadata from the files and write those into asset fields. This would allow to edit your project (portfolio etc.) in an external app like adobe lightroom. :)  
> **username_3**: Yeah, calling it "so rare" was probably an overkill. I'm still leaning towards the plugin route, though, since the methods are all there in the service and AssetFolderModels already have methods for traversing the tree.     As for the metadata - it's on the list, but that will most likely require Imagick installed.  
> **username_4**: Old link - but a dead one.  

---

