Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8758767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:37:59+00:00 2026-06-13T14:37:59+00:00

I have two separate pieces of code I’m trying to combine. The first counts

  • 0

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) &gt; 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 &lt; (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 &lt; (1440 * 30) and count(child::DocTypeAlias) &gt; 1">
            <p><xsl:value-of select="$datediff &lt; (1440 * 30) and count(child::DocTypeAlias)"/> new pages</p>
        </xsl:when>
        <xsl:otherwise>
            <p><xsl:value-of select="$datediff &lt; (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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:38:01+00:00Added an answer on June 13, 2026 at 2:38 pm

    With many thanks to Chriztian Steinmeier:

     <!-- The date calculation stuff -->
    <xsl:variable name="today" select="umb:CurrentDate()" />
    <xsl:variable name="oneMonthAgo" select="umb:DateAdd($today, 'm', -1)" />
    
    <!-- Grab the nodes to look at -->
    <xsl:variable name="nodes" select="$currentPage/DocTypeAlias" />
    
    <!-- Pages created within the last 30 days -->
    <xsl:variable name="newPages" select="$nodes[umb:DateGreaterThanOrEqual(@createDate, $oneMonthAgo)]" />
    <xsl:template match="/">
      <xsl:choose>
        <xsl:when test="count($newPages)">
          <p> <xsl:value-of select="count($newPages)" /> <xsl:text> New Page</xsl:text>
            <xsl:if test="count($newPages) &gt; 1">s</xsl:if>
          </p>
        </xsl:when>
        <xsl:otherwise>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two pieces of jquery code, they work perfectly separate, but together -
I have two essentially separate applications for configuring two pieces of hardware sold by
Is it possible to combine Underscore's filter and map? I currently have two separate
We have two separate web-apps, say 'retailUI' and 'bulkUI'. These two are basically two
I have two separate applications (both part of the same system) that share a
I have two separate caches running in a JVM (one controlled by a third
I have two separate sets of tables in the same database that model the
We have two databases, in two separate locations. One of the databases resides in
Say I have two separate classes, A and B. I also have Repository class
I have a Cake website and it needs to have two separate logins, each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.