Copied to clipboard

Flag this post as spam?

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


  • J 351 posts 606 karma points
    Feb 10, 2018 @ 11:44
    J
    0

    Get count using XSLT

    I have a Doc Type called Blog - In short everything under a content node can create a blog. Along with this is the date for the blog. I'm trying to count the number of blogs for each month using XSLT and have the below but is giving me the incorrect count?

    <xsl:key name="MonthNo" match="Blog" use="substring(concat(currentDate, @createDate), 1,7)"/>
    
    <xsl:template match="Blog" mode="month">
    <xsl:variable name="DateBlog" select="concat(currentDate, @createDate)"/>
    <xsl:variable name="YearBlog" select="substring-before($DateBlog, '-')"/>
    <xsl:variable name="MonthBlog" select="substring($DateBlog,6,2)"/>
    <xsl:variable name="BlogsInMonth" select="key('MonthNo', substring($DateBlog,1,7))"/>
    <li>        
      <xsl:element name="a">
        <xsl:attribute name="href">
          <xsl:value-of select="umbraco.library:NiceUrl(1234)"/>?d=<xsl:value-of select="concat($MonthBlog, '-', $YearBlog)"/>
        </xsl:attribute>
        <xsl:value-of select="concat($monthNames[position()=$MonthBlog], ' (', count($BlogsInMonth),')')"/>
      </xsl:element>
    </li>
    

    Can anyone see where ive gone wrong or the mistake made? Struggling with this so any help is appreciated.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies