Copied to clipboard

Flag this post as spam?

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


  • Daniel Bardi 927 posts 2562 karma points
    Dec 02, 2010 @ 20:15
    Daniel Bardi
    0

    How do I getting a media parent id

    I know a media nodes xml is a bit different than content nodes xml.

    What is the best way to get a media item's parent node?

    I've tried @parentId with no success.

     I think I can't see the forest through the trees.

    Thanks in advance.

  • Sebastian Dammark 583 posts 1407 karma points
    Dec 02, 2010 @ 20:26
    Sebastian Dammark
    0

    You could try to play with xpath axes right here: http://pimpmyxslt.com/
    Take a look at the one called parent::

    Try something like this ./parent::folder

    As far as I know the parent element to a media has to be a folder, right ?

  • Daniel Bardi 927 posts 2562 karma points
    Dec 02, 2010 @ 20:35
    Daniel Bardi
    0

    Parent can be any type.. depends on how you setup media structure.  In most cases it's Folder.

    I'll try the parent:: element

  • Daniel Bardi 927 posts 2562 karma points
    Dec 09, 2010 @ 20:35
    Daniel Bardi
    0

    Didn't work.. any other suggestions?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 09, 2010 @ 20:50
    Tom Fulton
    0

    @parentID seems to work fine for me.  It is case sensitive though, were you using @parentID or @parentId?

    -Tom

  • Kim Andersen 1447 posts 2197 karma points MVP
    Dec 09, 2010 @ 21:34
    Kim Andersen
    0

    Hi Daniel

    You should be able to use @parentID. Let's say that you have a media picker with an alias of "myPicker". With this picker you'll select a media node that have a parent. Let's put that node in a variable like this:

    <xsl:variable name="selectedMedia" select="umbraco.library:GetMedia($currentPage/myPicker, 0)"/>

    Now you should be able to get the selected node's parent using the GetMedia extension and $selectedMedia/@parentID. E.g. you could write out the parent node in a textarea to see the XML of that node like this:

    <textarea>      
         <xsl:copy-of select="umbraco.library:GetMedia($selectedMedia/@parentID, 1)"/>
    </textarea>

    /Kim A

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies