Copied to clipboard

Flag this post as spam?

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


  • Bijesh Tank 192 posts 420 karma points
    Sep 15, 2011 @ 18:15
    Bijesh Tank
    0

    Get count on nodes

    Hi,

    In my my content, I have a structure like this:

    - Home
    -- News
    --- 2010
    ---- October 2010
    ---- November 2010
    ---- December 2010
    --- 2011
    ---- January 2011
    ---- Febraury 2011
    ---- March 2011
    ---- April 2011
    ---- May 2011
    ---- June 2011
    ---- July 2011
    ---- August 2011
    ---- September 2011

    Each of the levels has the same doc type called 'News'. Basically what I want is a count of all the months on level 4, i.e. in the example above the resultant count should be 12.

    What I have so far is this:

    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=2]/node [@nodeTypeAlias = 'News'">
       <xsl:sort select="@id" data-type="number" order="descending" />
       <xsl:value-of select="count(./node [@level = 4])"/> -
    </xsl:for-each>

     

    But it keeps returning the result 3 and 9 (3 in 2010 and 9 in 2011).  Im having trouble getting the total count for all nodes on level 4 which should be one result of 12. Anyone know how to do this?

    Thanks.

  • Bijesh Tank 192 posts 420 karma points
    Sep 15, 2011 @ 18:19
    Bijesh Tank
    0

    I should add that I'm using the old schema, v4.0

  • Euan Rae 105 posts 135 karma points
    Sep 15, 2011 @ 18:26
    Euan Rae
    0

    The reason it's doing that is because it's getting the count for each month.  You should be able to get the result by

    <xsl:value-ofselect="count($currentPage/ancestor-or-self::node [@level=2]/node [@nodeTypeAlias = 'News' and @level=4"])>
Please Sign in or register to post replies

Write your reply to:

Draft