Copied to clipboard

Flag this post as spam?

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


  • Vincent Ashby-Smith 67 posts 196 karma points
    Jan 20, 2010 @ 17:33
    Vincent Ashby-Smith
    0

    Anyone see whats wrong with this?

    Hi can anyone see whats wrong with this, i get errors in it, but it looks ok to me!

     

    <a href="{umbraco.library:NiceUrl($currentPage/ancestor-or-self::node/data[@alias='caseStudyLink1'])}"></a>

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jan 20, 2010 @ 17:48
    Lee Kelleher
    0

    Hi Vincent,

    Have you checked the value of the XPath? It could be that it's empty, or not numeric?

    <xsl:value-of select="$currentPage/ancestor-or-self::node/data[@alias='caseStudyLink1']" />

    Cheers, Lee.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 20, 2010 @ 22:29
    Chriztian Steinmeier
    0

    Hi Vincent,

    You're probably just posting a small snippet of the real code, but just in case you're not:

     

    1. The link has no content so no clickable text/content will show up (OK, cheap shot - I know :-)
    2. When you save this, you'll likely get errors because your XSLT is tested against the "Content" node, which has no ancestor element named "node", neither is it called "node" itself, so the call to NiceUrl() fails with something like "Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value)"

     

    So you'll need to perform a test for the property value OR check the Skip testing (ignore errors) checkbox when saving (!). 

    /Chriztian

  • Paul Blair 466 posts 731 karma points
    Jan 20, 2010 @ 23:19
    Paul Blair
    0

    A couple fo theories I haven't tested:

     - according to this documentation ancestor-or-self could be bringing back multiple nodes if they have the caseStudyLink1 alias.

     - And you may have to explicitly use the @id attribute within niceURL as it expects an Int

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jan 20, 2010 @ 23:26
    Kim Andersen
    0

    Sometimes I have had luck by putting the whole Xpath in a variable, and then include the variable in the href. Like this:

    <xsl:variable name="link" select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::node/data[@alias='caseStudyLink1'])}"/>
    <a href="{$link}">My Link</a>

    You could try it out...

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft