I have two separate pieces of code I’m trying to combine.
The first counts the number of child pages and displays a number:
e.g. 8 child pages (or child page, if only 1 page)
<xsl:choose>
<xsl:when test="count(child::DocTypeAlias) > 1">
<p><xsl:value-of select="count(child::DocTypeAlias)"/> child pages</p>
</xsl:when>
<xsl:otherwise>
<p><xsl:value-of select="count(child::DocTypeAlias)"/> child page</p>
</xsl:otherwise>
The code detects if the page was created within the last 30 days:
<xsl:variable name="datediff" select="umbraco.library:DateDiff(umbraco.library:ShortDate(umbraco.library:CurrentDate()), umbraco.library:ShortDate(@createDate), 'm')" />
<xsl:if test="$datediff < (1440 * 30)">
<p>New</p>
</xsl:if>
I want to combine them so I can get a count of child pages and a count of the “new” pages.
e.g. 8 child pages – 2 new pages
I’ve tried the following but it doesn’t return the correct values:
<xsl:variable name="datediff" select="umbraco.library:DateDiff(umbraco.library:ShortDate(umbraco.library:CurrentDate()), umbraco.library:ShortDate(@createDate), 'm')" />
<xsl:choose>
<xsl:when test="$datediff < (1440 * 30) and count(child::DocTypeAlias) > 1">
<p><xsl:value-of select="$datediff < (1440 * 30) and count(child::DocTypeAlias)"/> new pages</p>
</xsl:when>
<xsl:otherwise>
<p><xsl:value-of select="$datediff < (1440 * 30) and count(child::DocTypeAlias)"/> new page</p>
</xsl:otherwise>
</xsl:choose>
It returns: “true new pages” I don’t know how to get it to display the number (2 new pages).
Can anyone help? Cheers, JV
With many thanks to Chriztian Steinmeier: