I have a media structure where the client can create nested folders (there's no limit, although they will tend to be 2-5 levels deep) and add files to those folders. The folders may be assigned custom properties. Each level of folder has is the same media type, so each level has the same optional properties.
What I need to be able to do is pull out a list of all of the image and file media items from anywhere in this folder structure and output the file name, along with a string of the id values of any of the custom properties assigned to the media items or parent folders of those media items. So essentially, any property assigned anywhere in the media structure should inherit all the way to the final image or file.
The output I'm looking for at the moment would be like this:
So you have the file path of the item, plus a space-separated string of the property ids assigned to this media item or inherited from any ancestor.
The way I've set this up works but it uses a lot of individual 'getmedia' calls within various templates. I've tested and it doesn't scale well. I think there must be a better way to do it, but I'm a little bogged down now to see clearly!
Inherit properties on media items
Hi,
I have a media structure where the client can create nested folders (there's no limit, although they will tend to be 2-5 levels deep) and add files to those folders. The folders may be assigned custom properties. Each level of folder has is the same media type, so each level has the same optional properties.
What I need to be able to do is pull out a list of all of the image and file media items from anywhere in this folder structure and output the file name, along with a string of the id values of any of the custom properties assigned to the media items or parent folders of those media items. So essentially, any property assigned anywhere in the media structure should inherit all the way to the final image or file.
The output I'm looking for at the moment would be like this:
<ul>
<li>/media/1234.jpg 1111 1200</li>
<li>/media/1234.png 1131 1118 1200</li>
<li>/media/1234.jpg 1480</li>
</ul>
So you have the file path of the item, plus a space-separated string of the property ids assigned to this media item or inherited from any ancestor.
The way I've set this up works but it uses a lot of individual 'getmedia' calls within various templates. I've tested and it doesn't scale well. I think there must be a better way to do it, but I'm a little bogged down now to see clearly!
Can anyone suggest a better way to do this?
Thanks
Amazing what a quick walk around the harbour can do to clear your mind!
It's actually quite simple. For future reference, the rough code (not outputting exactly what's above, but shows basic logic) is like this:
is working on a reply...