Copied to clipboard

Flag this post as spam?

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


  • Christophe 23 posts 43 karma points
    Jun 21, 2010 @ 19:57
    Christophe
    0

    Sub-Navigation Events Publishing

    Hello,

    On my home page I have a side bar that has the 3 future events (the code is below). The problem is if I keep pas events published then it will not show anything because it takes the first 3 events including past ones. Until I worked around this by un-publishing past evetns until today so the next 3 are in the future. BUT now I have a calendar that pulls from events that are published. I would like to show the past events on the calendar or else it looks like we had nothing up until today. My list of events (on the events page) shows only the future events.

    I would like show the next three events from today but keep all past events published so that the calendar shows all.

    I am not a developper but a somewhat curious and adept end-user. Any help would be greatly appreciated.

    Merci, thank you,

    Christophe

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library"
     exclude-result-prefixes="msxml umbraco.library">

        <xsl:output method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="currentPage"/>
       
        <xsl:variable name="noOfItems" select="3" />
        <xsl:template match="/">
             <ul class="events">
                <xsl:for-each select="$currentPage/ancestor-or-self::node//node [@nodeTypeAlias ='NewsEventsList']/node [@nodeTypeAlias = 'EventItem']">
                    <xsl:sort select="data [@alias='eventDate']" order="ascending"/>
      <xsl:if test="umbraco.library:DateGreaterThanOrEqualToday(data [@alias='eventDate'])">
                        <!-- Position() <= $noOfItems -->
                        <xsl:if test="position()&lt;= $noOfItems">
                         <li>
                                 <a class="title" href="{umbraco.library:NiceUrl(@id)}">
                                     <em>
                                        <xsl:choose>
                                         <xsl:when test="@nodeTypeAlias = 'EventItem'">
             <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias='eventDate'], 'dddd, d MMMM')"/><br/>
             <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias='eventDate'], 't')"/>
                                         </xsl:when>
                                         <xsl:otherwise>
                                                <xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'dddd, d MMMM yyyy')"/>
                                         </xsl:otherwise>
                                        </xsl:choose>
                                     </em>
                                     <span>
                                     <xsl:value-of select="@nodeName"/>
                                     </span>
                             </a>
            <p>
             <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(data [@alias = 'bodyText']), 60, '...')" />
            <span class="more"><a href="{umbraco.library:NiceUrl(@id)}">Learn more</a></span>
                                 </p>
               </li>
                     </xsl:if>
      </xsl:if>
                    
                </xsl:for-each>
            </ul>
        </xsl:template>
    </xsl:stylesheet> 
  • Josh Townson 67 posts 162 karma points
    Jun 22, 2010 @ 00:17
    Josh Townson
    0

    Hi Christophe,

    You just need to modify the xPath which selects the events nodes. Change

    <xsl:for-each select="$currentPage/ancestor-or-self::node//node [@nodeTypeAlias ='NewsEventsList']/node [@nodeTypeAlias = 'EventItem']">

    to be

    <xsl:for-each select="$currentPage/ancestor-or-self::node//node [@nodeTypeAlias ='NewsEventsList']/node [@nodeTypeAlias = 'EventItem' and umbraco.library:DateGreaterThanOrEqualToday(data [@alias='eventDate'])]">

    and then remove the date test (leave the position one :)

    /Josh

  • Christophe 23 posts 43 karma points
    Jun 25, 2010 @ 05:12
    Christophe
    0

    Wow, that works like a charm, thank you so much for your help.

    Christophe

Please Sign in or register to post replies

Write your reply to:

Draft