Copied to clipboard

Flag this post as spam?

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


  • Geoff Stokes 19 posts 38 karma points
    Sep 01, 2011 @ 04:59
    Geoff Stokes
    0

    Dynamically retrieving href for static object.

    Hi there,

    I have an object for which I need it to retrieve the href parameter from a content picker.

    I know that the code I need in order to get the URL is as follows:

    umbraco.library:NiceUrl(number(./data [@alias = 'northRegionLink']))

    But I am unsure how I would insert this in an (Rather complex - it is inside an image map) object's href.

    Is it possible to create a macro and insert it inside the href declaration? If so, how would I do that?

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Sep 01, 2011 @ 05:14
    Peter Gregory
    0

    Yes its possible to create a macro to retrieve this link.

    to put it in your href you do just that.

    <a href='<umbraco:macro alias="yourMacroName" source="[#northRegionLink]" runat="server" />'></a>

    obviously you would need to create a Macro that accepts a parameter source and then do your usual Umbraco Library call to get the link back.

     

  • Geoff Stokes 19 posts 38 karma points
    Sep 01, 2011 @ 05:59
    Geoff Stokes
    0

    Okay, passing the value to the macro seems to be working fine, but how do I simply output the value of

    umbraco.library:NiceUrl(linkNode)

    where linkNode is my parameter?

  • Geoff Stokes 19 posts 38 karma points
    Sep 01, 2011 @ 06:19
    Geoff Stokes
    0

    I have ammended this to;

    <xsl:value-of select="umbraco.library:NiceUrl(string(/macro/linkNode/node/id))"/>

    However, I stil recieve a System.OverflowException;

    System.OverflowException: Value was either too large or too small for an Int32. 
  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Sep 01, 2011 @ 06:23
    Peter Gregory
    0

    just use a

    <xsl:value-of select="umbraco.library:NiceUrl($linkNode)"/>

    This assumes that you have created the variable for linkNode.

    <xsl:variable name="linkNode" select="/macro/linkNode"/>
  • Geoff Stokes 19 posts 38 karma points
    Sep 01, 2011 @ 06:27
    Geoff Stokes
    0

    I still recieve the OverflowException.

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Sep 01, 2011 @ 07:12
    Peter Gregory
    0

    Wrap the niceurl line with an xsl-if like this.

    <xsl-if test="$linkNode !=''">
    <xsl:value-ofselect="umbraco.library:NiceUrl($linkNode)"/>
    </xsl:if> 

    This should sort it for you.

Please Sign in or register to post replies

Write your reply to:

Draft