This is a tricky one for me... How do I get all of the File descendants of a node that have an ancestor of a certain type?
In other words, I have a Media Type called "DocumentLibrary". I want to get a consolidated collection of all of the Files in my entire Media section that are beneath a DocumentLibrary folder.
Does that make sense? I realize I can get all of the DocumentLibrary folders and loop through them OR get all of the Files, but I only want Files that are BELOW a DocumentLibrary folder.
Perhaps you should take a look at the Umbraco helpers, there is a method called MediaAtRoot, and there is also a typed version of this. With this you should return a dynamic object, representing the root IPublishedContent entity in the Media tree.
Dennis, I know how to get the MediaRoot but I was wondering if anyone knew a single query that would allow me to get all of the Files beneath all of the Documen Library folders. Sort of like "//documentLibrary//File" in XPath...
Get Media Files With Ancestor of Type...
This is a tricky one for me... How do I get all of the File descendants of a node that have an ancestor of a certain type?
In other words, I have a Media Type called "DocumentLibrary". I want to get a consolidated collection of all of the Files in my entire Media section that are beneath a DocumentLibrary folder.
Does that make sense? I realize I can get all of the DocumentLibrary folders and loop through them OR get all of the Files, but I only want Files that are BELOW a DocumentLibrary folder.
Umbraco.MediaAtXpath() might work but that doesn't exist, which is strange...
Hi Robert,
Perhaps you should take a look at the Umbraco helpers, there is a method called MediaAtRoot, and there is also a typed version of this. With this you should return a
dynamic
object, representing the rootIPublishedContent
entity in the Media tree.The documentation is here: https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/#MediaAtRoot%28%29
Hope this can help you further.
/Dennis
Dennis, I know how to get the MediaRoot but I was wondering if anyone knew a single query that would allow me to get all of the Files beneath all of the Documen Library folders. Sort of like "//documentLibrary//File" in XPath...
is working on a reply...