Copied to clipboard

Flag this post as spam?

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


  • Tim Melis 22 posts 43 karma points
    Apr 05, 2011 @ 15:53
    Tim Melis
    0

    Link to parent node

    Hi,

    I'm trying to create a link to a parent (home / level 0) node in my XSLT file. When trying to save the file, a error appeirs: "System.OverflowException: De value is to large or to small for a Int32.

     

    Does anyone what's wrong? Thanx for your help.

     

     

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="HomeNode" select="$currentPage/parent::node" />
    <xsl:template match="/">

      <tr>
           <td class="TableCellNavLeft">    
           <href="{umbraco.library:NiceUrl($HomeNode/@id)}">
              Home</a>
          </td>
      </tr>


    </xsl:template>
    </xsl:stylesheet> 

  • Rich Green 2246 posts 4008 karma points
    Apr 05, 2011 @ 15:56
    Rich Green
    0

    Try this

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:param name="currentPage"/>
    <xsl:variable name="HomeNode" select="$currentPage/parent::node" />
    <xsl:template match="/">
    
    <xsl:if test="$HomeNode != '' ">
    
      <tr>
           <td class="TableCellNavLeft">    
           <a href="{umbraco.library:NiceUrl($HomeNode/@id)}">
              Home</a>
          </td>
      </tr>
    
    </xsl:if>
    
    </xsl:template>
    </xsl:stylesheet>

    Explaination here http://our.umbraco.org/forum/developers/xslt/3102-Using-niceurl-Value-was-either-too-large-or-too-small-for-an-Int32-

    Rich

  • Tim Melis 22 posts 43 karma points
    Apr 05, 2011 @ 16:55
    Tim Melis
    0

    Hi Rich,

    Thanks for your feedback. The error is gone. That's super. But I also have no output. For some reason the link is not generated. 

    Does anyone know why ?

    Tim

  • Rich Green 2246 posts 4008 karma points
    Apr 05, 2011 @ 17:14
    Rich Green
    0

    Are you trying to find the home node or the parent node? 

    Also which version of Umbraco are you using.

    Rich

  • Tim Melis 22 posts 43 karma points
    Apr 05, 2011 @ 17:41
    Tim Melis
    0

    Hi Rich,

    I'm trying to create a link pointing to the home node (level 0), to be used on pages below the home node...  

    I'm currently using 4.5.2.

    Tim

     

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Apr 05, 2011 @ 17:44
    Kim Andersen
    0

    Hi Tim

    If you just want to link to your homepage you can just do like this:

    <a href="/">Home</a>

    /Kim Andersen

  • Tim Melis 22 posts 43 karma points
    Apr 05, 2011 @ 18:07
    Tim Melis
    0

    Hey Kim,

    Thanks for your feedback. Your provided solution is perfect ... I was trying to solve a problem by using XSLT but the solution was simple plain old html...

    Thanks Kim

    Tim

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Apr 05, 2011 @ 18:49
    Kim Andersen
    0

    No problem Tim.

    In XSLT, you can grab the top most node in your site with this piece of code:

    <xsl:variable name="HomeNode" select="$currentPage/ancestor-or-self::*[@level='1']" />
    <xsl:template match="/">

    <xsl:if test="$HomeNode != '' ">

     
    <tr>
           
    <td class="TableCellNavLeft">    
           
    <a href="{umbraco.library:NiceUrl($HomeNode/@id)}">
              Home
    </a>
         
    </td>
     
    </tr>

    </xsl:if>

    </xsl:template>

    Well, at least that would work (with the new XML schema) if yout top most node is located on level 1 which is the the most used way to structure a site in Umbraco :)

    /Kim Andersen

Please Sign in or register to post replies

Write your reply to:

Draft