Copied to clipboard

Flag this post as spam?

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


  • Alec Colebrook-Clark 134 posts 258 karma points
    Aug 14, 2009 @ 12:54
    Alec Colebrook-Clark
    0

    Media Picker Macro

    Howdy

    Ive got a macro for rendering the media selected by the user. Its passing through the file location (the number) but i can't seem to create the correct pointer. my attempt Is as follows

         <xsl:if test="$content != '' ">
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data[@alias= $content], 'false')/data [@alias = 'umbracoFile']"/>
    </xsl:if>

    I've done it before but i didnt use variables (i have several media items on one page and i want to reuse this macro)

    any help is aprreciated.

    Thanks

    Alec

  • Warren Buckley 2089 posts 4578 karma points MVP ∞ admin hq c-trib
    Aug 14, 2009 @ 12:59
    Warren Buckley
    2

    Test it with hardcoded values first rather than variables first to make sure your xPath is correct etc...

    Then if that works - ouput your variables to make sure the correct info/data is being passed in.

    Hope this helps you out.
    Come back if your still stuck.
    Warren :)

  • Søren Linaa 255 posts 208 karma points
    Aug 14, 2009 @ 13:02
    Søren Linaa
    100

    Can you show us the entire xslt.

    I see a problem in your $content - what's that?

    in your value-of - you use another $content or is this the same.

     <xsl:value-of select="umbraco.library:GetMedia($currentPage/data[@alias= $content]
  • Alec Colebrook-Clark 134 posts 258 karma points
    Aug 17, 2009 @ 10:34
    Alec Colebrook-Clark
    0

    @warren - I've tested the variables and they are outputting the correct value... I think (its showing a number which I understand is the value of the media item?) I shall hardcode it now and let you know.

    @Soren - Yes its the same $content, thats the variable containing the media file name (again I understand it to be the media file name) its used to check if there is something in it and then it runs the value-of.

    Thanks for the replies!

    Alec

  • Alec Colebrook-Clark 134 posts 258 karma points
    Aug 17, 2009 @ 10:42
    Alec Colebrook-Clark
    0

    Ok apologies for the double post. Just changed the code to

    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data[@alias= 'ecocover'], 'false')/data [@alias = 'umbracoFile']"/>

    which works, ecocover is currently the value I am passing into the variable $content.

    So I must be doing something right!

  • Alec Colebrook-Clark 134 posts 258 karma points
    Aug 17, 2009 @ 10:50
    Alec Colebrook-Clark
    0

    and just to top it off, the usual happens.

    Sorted it out within 10 minutes of playing with it. Thanks for the help guys! the solution was

        <xsl:if test="$content != '' ">
    <xsl:value-of select="umbraco.library:GetMedia($content, 'false')/data [@alias = 'umbracoFile']"/>
    </xsl:if>

    I must have tried every combination bar that one!

    again, thanks!

    Alec

  • 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