Copied to clipboard

Flag this post as spam?

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


  • Daniel Horn 319 posts 344 karma points
    Jan 16, 2011 @ 16:18
    Daniel Horn
    0

    Recursive property in XSLT

    I have a property called DVoverskrift on my doc type called forside.

    My tree is like this:

    Forside

    - Textpage

    -- textpage

    -- textpage

    - Contact page

    On all pages i need to use the property DVoverskrift which is set on Forside.

    How do i do this?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 16, 2011 @ 16:22
    Jan Skovgaard
    1

    Hi Daniel

    You should be able to achieve this by using the ancestor-or-self axe...

    So you would write something like this

    <xsl:value-of select="$currentPage/ancestor-or-self::*[@isDoc]/DVoverskrift" />

    Hope this helps.

    /Jan

  • Daniel Horn 319 posts 344 karma points
    Jan 16, 2011 @ 16:33
    Daniel Horn
    0

    That worked Jan, thanks! :)

  • Daniel Horn 319 posts 344 karma points
    Jan 20, 2011 @ 13:54
    Daniel Horn
    0

    How about pulling a media item recursively? Same scenario. 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 20, 2011 @ 16:09
    Jan Skovgaard
    0

    Hi Daniel

    Yes it should be the same scenario - are you having trouble?

    /Jan

  • Daniel Horn 319 posts 344 karma points
    Jan 20, 2011 @ 16:17
    Daniel Horn
    0

    If I've got it right, then isDoc checks if its a document (node?) and the media item isn't - so that's one problem.

    Ive tried a few things but nothing is really working out - so how would you pull out a media item? :)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 20, 2011 @ 23:29
    Jan Skovgaard
    0

    Hi Daniel

    Ok, then try to remove the check on @IsDoc - you can always use the old trick of making the <textarea><xsl:copy-of select="$yourvariable" /></textarea> to see what XML gets returned. Mr. Steinmeier himself have actually made a package to make this daunting task easier. I'm sure it can save you some time figuring it all out.

    Otherwise the media iterator package could perhaps help you out. I think there is an XSLT file in it, which you can modify to your needs. Check it out :-)

    /Jan

  • Daniel Horn 319 posts 344 karma points
    Jan 21, 2011 @ 19:29
    Daniel Horn
    0

    Thanks for you reply Jan!

    <xsl:variable name="url" select="$currentPage/ancestor-or-self::*[@isDoc]/nBLink"/>

    Gives me the nodeid 1156 of the media item.. hmm

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 21, 2011 @ 19:32
    Jan Skovgaard
    0

    Hi Daniel

    Yup, that's correct. It returns the id of the media node.

    You need to pass that id to the GetMedia() extension, which you can read more about here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

    I think that you should be able to figure out how to go on when you have seen the example on the page.

    Otherwise just let us know, right? ;-)

    /Jan

  • Daniel Horn 319 posts 344 karma points
    Jan 23, 2011 @ 20:44
    Daniel Horn
    0

    Thanks Jan - I'm gonna owe you are couple of beers at codegarden :)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 23, 2011 @ 20:48
    Jan Skovgaard
    0

    You're very welcome. I'm only happy to be able to help.

    Aaah, free beer just tastes better :D

    /Jan

  • 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