Copied to clipboard

Flag this post as spam?

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


  • Balt 1 post 21 karma points
    Mar 21, 2011 @ 19:24
    Balt
    0

    Navigation - I only want to display the first 12 links

    Hello,

    I'm fairly new to Umbraco still and XLST for that matter. I have the main navigation working fine, the side navigation also works fine. However, I am trying to display only part of the list for the navigation and I'm not sure how to do this.

    More detail:

    We have a special "item of the month" and we want only 12 months to be displayed, so since it is March now, we don't need January and February displayed. The navigation is in an UL as listed items.

    I don't think I want a substring code since the exact characters will change depending on the month... but I'm not exactly sure where I should start or if anyone has ideas?  Right now I have this displayed:

    • February 2011
    • January 2011
    • December 2010
    • Novermber 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010

    I want to have it so it knocks off the last 2 on the list each time.  So based on the current list, I would want Feb. 2010 and Jan. 2010 to fall off the list and when we add March 2011, I would want March 2010 to fall off the list and so on.

    Any ideas on the subject?  Thanks in advanced!

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 21, 2011 @ 19:43
    Tom Fulton
    2

    Hi,

    One way to achieve this is using the position() function, you can add it to your for-each selector or inside the loop, ex:

    <xsl:for-each select="$currentPage/* [@isDoc][string(umbracoNaviHide) != '1'][position() &lt; 13]">

    or

    <xsl:for-each select="$currentPage/* [@isDoc][string(umbracoNaviHide) != '1']">
    <xsl:if test="position() &lt; 13">
    ...
    </xsl:if>
    </xsl:for-each>

    Hope this helps,
    Tom

     

     

Please Sign in or register to post replies

Write your reply to:

Draft