Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Robert J. Bullock 386 posts 405 karma points
    Apr 09, 2015 @ 22:12
    Robert J. Bullock
    0

    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.

     

  • Robert J. Bullock 386 posts 405 karma points
    Apr 09, 2015 @ 22:28
    Robert J. Bullock
    0

    Umbraco.MediaAtXpath() might work but that doesn't exist, which is strange... 

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 09, 2015 @ 23:30
    Dennis Aaen
    0

    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 root IPublishedContent 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

  • Robert J. Bullock 386 posts 405 karma points
    Apr 09, 2015 @ 23:40
    Robert J. Bullock
    0

    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...

Please Sign in or register to post replies

Write your reply to:

Draft