Copied to clipboard

Flag this post as spam?

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


  • Thom 13 posts 31 karma points
    Nov 02, 2009 @ 19:07
    Thom
    0

    Extending the xslt to pull an image reference

    Hi,

    this works great for me but I'm trying to add some further information to the 'a' element. Specifically a class which must include a reference to an image in the media library (this gets used for an image rollover on hovering over the list item). The image required is specified in the target page (@link) in a Media Picker property called introImage.

    Having a complete mental block here, any help much appreciated! I'm sure this is going to be dead simple. If more explanation required happy to supply.

     

    ....
    <xsl:otherwise>
    <xsl:attribute name="href">
    <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
    </xsl:attribute>
    <xsl:attribute name="class">
       <xsl:value-of select="?????????????????????" />
    </xsl:attribute>
    </xsl:otherwise>
    ....
  • skiltz 501 posts 701 karma points
    Nov 02, 2009 @ 20:23
    skiltz
    0
    <xsl:value-of select="umbraco.library:GetMedia(data [@alias = 'introImage'],'false')/data [@alias = 'umbracoFile']"/>
  • Thom 13 posts 31 karma points
    Nov 02, 2009 @ 22:04
    Thom
    0

    Thanks for the replay skiltz. I now get the "Value was either too large or too small for an Int32" error and think could get round that with an if test. But I wonder if your code is looking in the correct place for the introImage - the property isn't in the $currentPage but in the page referenced by ./@link in the snippet I posted.

    Should I get the node id from @link, store it in a parameter and then pass that to GetMedia or can I reference the 'remote' property directly with @link? Either way I'm stuck.

    Hope I'm making some sense, reading it back I'm not sure I am ;-)

  • skiltz 501 posts 701 karma points
    Nov 02, 2009 @ 22:20
    skiltz
    0

    Try ticking "Skip Testing(ignore errors) at the top of the xslt editor and then view your page to see if the value came through.

  • Thom 13 posts 31 karma points
    Nov 02, 2009 @ 23:53
    Thom
    0

    no joy. Page is rendered with "Error parsing XSLT file: \xslt\getRelatedLinks.xslt". Even without that ticked I can successfully save the xslt file but visualising xslt raises the error. The xslt seems valid but not retrieving the value I need.

    What I'm struggling with is how to reference a property on another page with the @link value from the current page being the only reference I have. The xslt grabs the url fine using this (<xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>) but I'm stuck with the syntax to grab the introImage property of that (@link) page.

    Thanks for your help so far!

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 03, 2009 @ 08:59
    Dirk De Grave
    0

    Hi Thom,

    If you need the introImage property from the page referenced by @link, you only need:

    <xsl:value-of select="umbraco.library:GetXmlNodeById(./@link)/data [@alias = 'introImage']" />

    you may need to surround this code snippet with an <xsl:if> as './@link' won't have a value until runtime, thus resulting in a "Value was either too large or too small for an Int32" error

    Hope this helps.

    Regards,

    /Dirk

     

  • Thom 13 posts 31 karma points
    Nov 03, 2009 @ 14:30
    Thom
    0

    Thanks for both of your help! Dirk, that did the trick. Everything working now..

Please Sign in or register to post replies

Write your reply to:

Draft