Copied to clipboard

Flag this post as spam?

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


  • Jeremy Tolsdorf 4 posts 24 karma points
    Feb 16, 2010 @ 04:48
    Jeremy Tolsdorf
    0

    Number of events with PDCalendar

    I've been using the wonderful PDCalendar control from Peter D, it is a great control!  I have been able to customize the XSLT to do everything I want...until know.

    I have setup my calendar data using a top level Events Calendar node and organized my events into month-based folders underneath it.  I am trying to build a "Coming Soon" macro for my homepage, which displays the next 2 upcoming events within a rolling 30 day period, but am having trouble limiting my results to only 2 events.

    I have tried using position() within my for-each statements, but since the events may come from different nodes (i.e. 1 from February and 1 from March) their position values are (I think) relative to their parent folder.  What I end up with is 1 event from February and 2 from March, but I really only want 2 total.  I've tried using a counter or some kind of tracking method to limit my XLST for-each statements, but XSLT doesn't seem to allow for that.

    Does anyone have a suggestion for handling a scenario like this?  I would appreciate any insight.

    Thanks,

    Jeremy

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Feb 16, 2010 @ 10:20
    Peter Dijksterhuis
    1

    Hi,

    you can use position just fine. Being on different parent-nodes should not matter.

    Here's a little example:

    <xsl:variable name="events" select="pdcalendar:GenerateDates('2010-01-01','2010-12-31','Event')" />
    <xsl:template match="/">
    <xsl:for-each select="$events/node/event">
    <xsl:if test="position() &lt; 3">
    <xsl:value-of select="@id"/>
    </xsl:if>
    </xsl:for-each>
    </xsl:template>

    HTH,

    Peter

Please Sign in or register to post replies

Write your reply to:

Draft