Copied to clipboard

Flag this post as spam?

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


  • Marc 21 posts 40 karma points
    May 20, 2011 @ 20:34
    Marc
    0

    make a link out of a node

    Hi,

    I have  a line of program that just shows a node name in screen like this:

    <xsl:value-of select="umbraco.library:GetXmlNodeById($deptrootid)/@nodeName"/>


    How do you make that a hyperlink to the page?

     

    Thanks

  • Tom Fulton 2030 posts 4996 karma points c-trib
    May 20, 2011 @ 20:40
    Tom Fulton
    0

    Hi,

    You should use the NiceUrl function and pass the ID of the node, ex:

    <a href="{umbraco.library:NiceUrl($deptrootid)}">
    <xsl:value-of select="umbraco.library:GetXmlNodeById($deptrootid)/@nodeName"/>
    </a>

    -Tom

  • Marc 21 posts 40 karma points
    May 20, 2011 @ 20:48
    Marc
    0

    when I added that there's a save error:

    Error occured

    System.OverflowException: Value was either too large or too small for an Int32.
    at System.Convert.ToInt32(Double value)
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

  • Tom Fulton 2030 posts 4996 karma points c-trib
    May 20, 2011 @ 20:49
    Tom Fulton
    0

    Try wrapping it in an if statement to ensure the variable has a value:

    <xsl:if test="$deptrootid != ''">
    <
    a href="{umbraco.library:NiceUrl($deptrootid)}">
     
    <xsl:value-of select="umbraco.library:GetXmlNodeById($deptrootid)/@nodeName"/>
    </a>
    </xsl:if>
  • Marc 21 posts 40 karma points
    May 20, 2011 @ 20:51
    Marc
    0

    ok thats work , keep wondering why theres error when i put that line, thanks.

  • Kim Andersen 1447 posts 2196 karma points MVP
    May 20, 2011 @ 22:18
    Kim Andersen
    0

    Hi Marc

    The reason why you get that error when saving, is because the ode will be excecuted at the time you hit the Save-button. But at that time, the $deptrootid is probably empty, so the NiceUrl-extension will fail.

    /Kim A

  • 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