2

I like to display a tree-like view of all files in an asset source:

  • Folder_X
    • File_A
    • File_B
    • Folder_Y
      • File_C
  • Folder_Z
    • ...

I know that I can iterate over all assets in a source ({% for file in craft.assets.sourceId('1') %}) but this gives just an alphabetically sorted list of all files. Maybe we need something like the nav-tag.

2 Answers 2

1

Yoursort, my answer was based on the assumption that the AssetsService could be used in templates. Ofcourse, only the variables can be used.

I don't have time to dive into this (now), but I think your best bet is to get all images, use `asset.folder' for each asset and 'rebuild' the hierarchical list of folder and their assets. Again, use cache ;)

1

I have created the Assets Browser Plugin which allows to browse an asset source or a specific folder on the frontend.

Although it is not a treeview it serves me well for outputting a download area on the website. It works even with the Internal Assets Plugin for a member-only area.

Your Answer

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

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