Copied to clipboard

Flag this post as spam?

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


  • Emil 3 posts 23 karma points
    Sep 04, 2012 @ 10:49
    Emil
    0

    Trouble with umbraco.library

    Umbraco 4.8.1

    I am trying to get var "url" into our for-each, where it's currently "select="$currentPage/*/* "

    The purpose of the XSLT is to create a macro that lists the blogs we have on our site, and use that macro in the master page. At this stage the makro is functional, but only at the homepage.

    Currently we're getting this error:

    Error occured

    System.OverflowException: Værdien var enten for stor eller for lille til en Int32. 
    ved System.Convert.ToInt32(Double value) 
    ved System.Double.System.IConvertible.ToInt32(IFormatProvider provider) 
    ved System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) 
    ved System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType) 
    ved System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) 
    ved url(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    ved Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    ved System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) 
    ved System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) 
    ved System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) 
    ved System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) 
    ved umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    <xsl:variable name="documentTypeAlias" select="string('Blog')"/>
    <xsl:variable name="numberOfPosts" select="4"/>
    <xsl:variable name="url" select="umbraco.library:NiceUrl($currentPage/data[@alias='Subpage'])"/>

    <xsl:template match="/">
    <!-- The fun starts here -->
    <ul>

      <xsl:for-each select="$currentPage/*/*[name() = $documentTypeAlias and string(umbracoNaviHide) != '1' ] ">
     
        <xsl:sort select="@createDate" order="descending" />
     <xsl:if test="position() &lt;= $numberOfPosts"<li>
        <href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="blogHeader"/>
       </a>
       <br />
       <div id="date">
    <xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'MMMM d, yyyy')"/>
       </div>
      </li>
      </xsl:if>
    </xsl:for-each>

    </ul>

    </xsl:template>
  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 04, 2012 @ 11:02
    Chriztian Steinmeier
    0

    Hi Emil,

    That error almost always has to do with an empty nodeId being sent to NiceUrl() (or another extension that takes a nodeId).

    In your case it's because you've accidentally used the syntax for the "legacy schema" when referencing the Subpage property (is it a property?)

    If it's a property, write it like this:

    <xsl:variable name="url" select="umbraco.library:NiceUrl($currentPage/Subpage)" />

     

    /Chriztian

  • Emil 3 posts 23 karma points
    Sep 04, 2012 @ 11:59
    Emil
    0

    Thanks for the fast answer.

     

    It should be a document type. It's the one I use for all pages except homepage.

    Obviously what you suggested did not work. Getting the same error. If there's anything else I need, please do tell :)

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 04, 2012 @ 12:09
    Chriztian Steinmeier
    0

    I thought so :)

    You need to specify the page for which you want the URL then...

    E.g., is it the URL of the 1st page below $currentPage? Then do:

    <xsl:variable name="url" select="umbraco.library:NiceUrl($currentPage/Subpage[1]/@id)" />

    (If there's only ever going to be a single subpage, you can take off the [1] predicate)

    Or maybe the Subpage named "Awesome blog":

    <xsl:variable name="url" select="umbraco.library:NiceUrl($currentPage/Subpage[@nodeName = 'Awesome blog']/@id)" />

     

    Hope you're able to solve it now, otherwise come back :-)

    /Chriztian

  • Emil 3 posts 23 karma points
    Sep 04, 2012 @ 12:30
    Emil
    0

    Ok, I tried what you wrote, it still only works on homepage, but on the other pages it writes this:

    What I am trying to do is to get it to work with all pages, while the macro is on the masterpage :)

    Error parsing XSLT file: \xslt\ListBlogs.xsl
Please Sign in or register to post replies

Write your reply to:

Draft