Copied to clipboard

Flag this post as spam?

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


  • Grant Stephen 18 posts 58 karma points
    Aug 30, 2012 @ 21:08
    Grant Stephen
    0

    latest article by date

    i am using a blog type senario for events ie date folders, each event has a date property which is used to hide the article after the date has past, however i have 4 different areas within the site to add events one for each section of our Scout group, is there a way i can show the next event only on the front page of my website?

    Explorer events
    2012
      08
                event1
               event2
            09
              event3
              event4
              event5
              event6

     

    assuming that the dates  for events 1 to 3 has passed i would like to show only event 4 on the home page

     

    thanks

     

    G

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Aug 30, 2012 @ 22:31
    Chriztian Steinmeier
    0

    Hi Grant,

    In XSLT you do that by selecting all the future events, attempting to run through them sorted ascending by date and then taking the first:

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umb="urn:umbraco.library"
        exclude-result-prefixes="umb"
    >
    
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
        <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
        <xsl:variable name="eventsRoot" select="$siteRoot/Events" /><!-- Change this to grab the top node for all events -->
    
        <xsl:variable name="futureEvents" select="$eventsRoot//Event[umb:DateGreaterThanOrEqualToday(eventDate)]" />
    
        <xsl:template match="/">
            <xsl:for-each select="$futureEvents">
                <xsl:sort select="eventDate" data-type="text" order="ascending" />
                <xsl:if test="position() = 1">
                    <xsl:apply-templates select="." />
                </xsl:if>
            </xsl:for-each>
        </xsl:template>
    
        <!-- Template for Events... -->
        <xsl:template match="Event">
            <div class="nextevent">
                <xsl:value-of select="@nodeName" />
                <!-- etc. -->
            </div>
        </xsl:template>
    
    </xsl:stylesheet>

     

    You need to change the stuff highlighted - basically the nodeTypeAlias of your event document type (Event) and the property alias of the date property (eventDate)  

    /Chriztian 

  • 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