Copied to clipboard

Flag this post as spam?

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


  • Stephen Davidson 216 posts 392 karma points
    Jun 17, 2012 @ 11:25
    Stephen Davidson
    0

    Link only working in certain sections

    I have the following code to display the site services in the footer area but my "view all" link only works when in the services home page...on any other page there is no link...all i want is the view all link to link to the services home page no matter what page you are  on.

     <xsl:output method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="currentPage"/>
        <xsl:variable name="noOfItems" select="6" />
        <xsl:param name="MaxNoChars" select="100" />
      
        <xsl:template match="/">

         <div class="services">
           <h3>Our Services</h3>   
               
                <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc]/esiServices/* [@isDoc]">
                    <xsl:sort select="@createDate" order="ascending"/>
                  
                    <!-- Position() <= $noOfItems -->
                    <xsl:if test="position()&lt;= $noOfItems">
     
                      <!-- TODO: strip HTML & truncate -->
                      <h4><href="{umbraco.library:NiceUrl(@id)}"<xsl:value-of select="@nodeName" /></a></h4>

                    </xsl:if>
                    
                </xsl:for-each>
             
           <p><href="{umbraco.library:NiceUrl($currentPage/@parentID)}"View all </a]</p>
         <br class="clearfloat" />
          </div>
        </xsl:template>

     

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Jun 17, 2012 @ 15:02
    Dan Okkels Brendstrup
    0

    I'm assuming that it is the "esiServices" node you want to link to? Currently you're linking to the current page's parent, so that's why it only works when you are on a specific service page. This should do it:

    <a href="{umbraco.library:NiceUrl($currentPage/ancestor-or-self::*[esiServices]/esiServices/@id)}">View all</a>

    It finds the nearest ancestor node (or the page itself) that has an esiServices child, and creates the link based on that child's @id attribute. If the parent page has a specific nodetype, you can improve performance by searching for that directly, e.g.:

    <a href="{umbraco.library:NiceUrl($currentPage/ancestor-or-self::Frontpage/esiServices/@id)}">View all</a>

     

  • Stephen Davidson 216 posts 392 karma points
    Jun 17, 2012 @ 15:45
    Stephen Davidson
    0

    thanks Dan, I had tried that but got an error...

     

    Error occured

    System.OverflowException: Value was either too large or too small for an Int32. 
    at System.Convert.ToInt32(Double value) 
    at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) 

     

    However i have just tired i again and check the box to ingore errors and it works, thanks again...

     

    S

Please Sign in or register to post replies

Write your reply to:

Draft