Copied to clipboard

Flag this post as spam?

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

  • Eric Boen 40 posts 64 karma points
    Aug 13, 2010 @ 07:26
    Eric Boen

    for-each loop and NiceURL in a template

    Not sure what I'm doing wrong here. I have a for-each loop and some Choose logic in the parent template.  The parent template calls this template and passes a node.  I'm able to loop through the list of children in the param node that is being passed in and I'm able to get the children @Id and @nodeName....but all the following variations of NiceRUrl give me the following exeption.

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

    <xsl:template name="DropLineNonActive">
        <xsl:param name="parent"/>
        <ul class="sub">
        <xsl:for-each select="$parent/*">
    <href="{umbraco.library:NiceUrl(@id)}"></a> <!--tried this, throws error-->

              <href="{umbraco.library:NiceUrl(./@id)}"></a<!--tried this, throws error-->

              <href="{umbraco.library:NiceUrl(current()/@id)}"></a<!--tried this, throws error-->

              <xsl:value-of select="@id"/><!--works as expected-->
              <xsl:value-of select="@nodeName"/><!--works as expected-->

    Not sure why this won't work.  Thanks for any advise you may have.


  • Chriztian Steinmeier 2717 posts 8185 karma points MVP 4x admin c-trib
    Aug 13, 2010 @ 09:20
    Chriztian Steinmeier

    Hi Eric,

    Are you on 4.5.1 or 4.0?

    For the record: The first is the one that you should use (the other two does the exact same thing with bigger byte-counts :-)

    If you're on 4.5.1 (which I suspect), you should add the [@isDoc] predicate to the $parent/* select, like this:

    <xsl:for-each select="$parent/*[@isDoc]">

    because the star will select all the properties as well...

    Why does the value-of statements "work"?

    - Because they will print the @id and @nodeName from the document node, and nothing from the properties - the properties on the other hand will fail in the NiceUrl() call because they have no @id attribute...



  • Eric Boen 40 posts 64 karma points
    Aug 13, 2010 @ 15:43
    Eric Boen

    @Chriztian - Yes I am using 4.5.1.  Thank you for the explanation, that does work.  I didn't realize that [@isDoc] predicate included the properties.  Great information!



Please Sign in or register to post replies

Write your reply to: