Copied to clipboard

Flag this post as spam?

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


  • Hassan Ata Ullah 6 posts 56 karma points
    Jul 04, 2013 @ 14:58
    Hassan Ata Ullah
    0

    Hi Umbraco masterminds :)

    I have created a documenttype with property alias linkId which contains the link to the external page. The idea was to replace  

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

    with

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

    but it didnt work instead i get exception cause niceurl take int as param I suppose. 

    System.OverflowException: Value was either too large or too small for an Int32. 

    <a>

     <xsl:attribute name="href">

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

     </xsl:attribute>

     <xsl:value-of select="$currentPage/linkId" />

    </a>

    Thanks

  • Rich Green 2246 posts 4008 karma points
    Jul 04, 2013 @ 15:01
    Rich Green
    0

    I'm going to have to guess what the question is here...

    You don't use NiceUrl on external link, you just use the link given.

    For a neat way of dealing with either internal or external links try http://ucomponents.org/data-types/url-picker/

    Rich

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 04, 2013 @ 15:07
    Dennis Aaen
    0

    Hi Hassan,

    Maybe this is the same question?

    http://our.umbraco.org/forum/developers/xslt/24167-Getting-value-of-External-Link.

    Else I think Rich´s solution looks quite exciting.

    /Dennis

  • Hassan Ata Ullah 6 posts 56 karma points
    Jul 04, 2013 @ 15:16
    Hassan Ata Ullah
    0

    Hi Dennis 

    Have seen that post and tried the soulution and the code looks like this: 

     <a href="{umbraco.library:NiceUrl(@id)}">
            <xsl:if test="normalize-space(linkId)">
                <xsl:attribute name="href">
                    <xsl:value-of select="linkId"/>
                </xsl:attribute>   
            </xsl:if>
        <xsl:value-of select="$currentPage/linkId"/>
        </a>

    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, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current) 
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) 
    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)

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 04, 2013 @ 15:18
    Stefan Kip
    0

    How about:

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

  • Hassan Ata Ullah 6 posts 56 karma points
    Jul 04, 2013 @ 15:24
    Hassan Ata Ullah
    0

    Hi kipusoep

    Still throws the same exception with 

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

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jul 08, 2013 @ 00:48
    Chriztian Steinmeier
    0

    Hi Hassan,

    That error usually always means that you're calling NiceUrl() with a null value (or a string like "hello") instead of an actual id.

    I would guess it happens when you save the file right now, because then Umbraco will try to run the macro using the Content node as $currentPage, which will result in NiceUrl() being called with null (the parent of Content neither has an id attribute, nor a linkId property).

    It could also happen if you're doing this in a for-each loop and one of the nodes you're selecting doesn't have a value in the linkId property - which will easily happen when you're testing the feature - you create the property and only save it on a single node. The other nodes doesn't get the property until they're republished somehow, and NiceUrl() will barf again.

    So you should always make sure that you're actually sending an id into NiceUrl(), GetXmlNodeById() etc. - you can do that with the if instruction:

    <xsl:if test="normalize-space($currentPage/linkId)">
        <xsl:value-of select="umbraco.libray:NiceUrl($currentPage/linkId)" />
    </xsl:if>

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft