Copied to clipboard

Flag this post as spam?

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


  • kentiler 76 posts 69 karma points
    Mar 07, 2010 @ 05:26
    kentiler
    0

    Can you help me limit results to data field in future?

    Hi,

    I have the following code used to display a list of classes each under the day of week for that class.  I only want to show the day of week if there is a class that is not already past.  I know I can use an If statement to stop the rendering of the class data for past dates with the following statement:

    <if test="umbraco.library:DateGreaterThanOrEqualToday( ./data [@alias='ClassDate'] )">

    but in the case where there is only one class and it is in the past, then the day of week will show up without any class.  Here's the entire XSLT file that I'm using.

    <?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
     xmlns:date="urn:Exslt.ExsltDatesAndTimes"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets date">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <!-- Create an XML helper variable -->
    <xsl:variable name="weekdays">
    <day name="Saturday" id="7" />
    <day name="Sunday" id="1" />
    <day name="Monday" id="2" />
    <day name="Tueday" id="3" />
    <day name="Wednesday" id="4" />
    <day name="Thursday" id="5" />
    <day name="Friday" id="6" />
    </xsl:variable>
    <xsl:template match="/">
    <xsl:apply-templates select="msxml:node-set($weekdays)/day" />
    </xsl:template>
    <!-- Actual output for each page -->
    <xsl:template match="node">
    <li>
    <xsl:value-of select="@nodeName" />
    </li>
    </xsl:template>
    <!-- Template for a <day> element in the $weekdays variable -->
    <xsl:template match="day">
    <xsl:variable name="days" select="$currentPage/node[date:dayinweek(data[@alias = 'ClassDate']) = current()/@id]" />
    <xsl:if test="$days">
    <h2><xsl:value-of select="@name" /></h2>
    <ul>
    <xsl:for-each select="$days">
    <!-- Start of Class -->
    <div class="title" id="classes"><xsl:value-of select="data [@alias = 'ClassTitle']"/><span> - <xsl:value-of select="data [@alias = 'ClassInstructor']"/></span></div>
    <div class="meta"><div id="date"><xsl:value-of select="umbraco.library:FormatDateTime(data [@alias = 'ClassDate'], 'MMMM dd, yyyy')"/></div>
    <div id="time"><xsl:value-of select="data [@alias = 'ClassTime']"/></div><div id="age"><xsl:value-of select="data [@alias = 'ClassAge']"/></div></div>
    <p class="content"><xsl:value-of select="data [@alias = 'ClassBody']" disable-output-escaping="yes" /></p>
    <div id="register"><a href="" >Register For This Class ></a></div>
    <!-- End of Class -->
    </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template> 
    </xsl:stylesheet>

    Thanks!

    --Kent

  • Tommy Poulsen 514 posts 708 karma points
    Mar 07, 2010 @ 10:25
    Tommy Poulsen
    0

    Hi Kent

    it would be easiest to add an extra condition to you your "days" variable definition - something like this:

    <xsl:variable name="days" select="$currentPage/node[date:dayinweek(data[@alias = 'ClassDate']) = current()/@id and umbraco.library:DateGreaterThanOrEqualToday( data [@alias='ClassDate']]" />

    >Tommy

Please Sign in or register to post replies

Write your reply to:

Draft