Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi..
I have an event calendar where I try to add a class to the td i the table for the current date, where I have tried with:
<xsl:variable name="currentDate" select="concat($day,'. ',$MonthName,' ',$Year)" /><xsl:if test="$currentDate"> <xsl:attribute name="class"> <xsl:text>today</xsl:text> </xsl:attribute></xsl:if>
and
<xsl:if test="umbraco.library:CurrentDate()"> <xsl:attribute name="class"> <xsl:text>today</xsl:text> </xsl:attribute></xsl:if>
but it adds the today class for all dates except the ones, where an empty class is added..
What do I need to add a class for todays date/current date..?
Bjarne
Hi Bjarne
Could you provide a bit more of the code? I would like to see more of the context if that's ok :)
/Jan
Okay, here is the full code :) It's basically the code to the event calendar in Business Website Starter Pack with some small modifications..
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" xmlns:date="http://exslt.org/dates-and-times" 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" exclude-result-prefixes="date exslt msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "><xsl:output method="xml" omit-xml-declaration="yes"/><xsl:param name="currentPage"/><xsl:template match="/"> <div class="event_main"> <xsl:value-of select="$currentPage/pageContent" disable-output-escaping="yes" /> <h2> <xsl:choose> <xsl:when test="$currentPage/pageHeading != ''"> <xsl:value-of select="$currentPage/pageHeading"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$currentPage/@nodeName"/> </xsl:otherwise> </xsl:choose> : <xsl:value-of select="$MonthName" /><xsl:text> </xsl:text><xsl:value-of select="$Year" /></h2> <div class="event_nav"> <p><xsl:text>Der vises i øjeblikket: </xsl:text><xsl:value-of select="$MonthName" /><xsl:text> </xsl:text><xsl:value-of select="$Year" /></p> <xsl:call-template name="PreviousMonthLink" /> <xsl:call-template name="NextMonthLink" /> </div> </div> <div class="event_sidebar"> <xsl:call-template name="Calendar" /> <p class="ical_export"> <a> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)" /><xsl:text>?altTemplate=iCalExportAll</xsl:text> </xsl:attribute> Eksportér alle events (iCal) </a> </p> </div> <div class="events_list"> <xsl:choose> <xsl:when test="count($currentPage//* [@isDoc and name()='Event' and Exslt.ExsltStrings:lowercase($currentMonthYear) = Exslt.ExsltStrings:lowercase(umbraco.library:FormatDateTime(./eventStartDateTime, 'MMMM,yyyy'))]) > 0"> <ul class="events_list"> <xsl:for-each select="$currentPage//* [@isDoc and name()='Event' and Exslt.ExsltStrings:lowercase($currentMonthYear) = Exslt.ExsltStrings:lowercase(umbraco.library:FormatDateTime(./eventStartDateTime, 'MMMM,yyyy'))]"> <xsl:sort select="current()/eventStartDateTime" order="ascending" /> <li> <div class="news_date"> <span class="month"><xsl:value-of select="umbraco.library:FormatDateTime(current()/eventStartDateTime, 'MMM')"/></span> <span class="day"><xsl:value-of select="umbraco.library:Replace(umbraco.library:FormatDateTime(current()/eventStartDateTime, ' d'), ' ','')"/></span> <span class="year"><xsl:value-of select="umbraco.library:FormatDateTime(current()/eventStartDateTime, 'yyyy')"/></span> </div> <div class="event_desc"> <h3><a href="{umbraco.library:NiceUrl(current()/@id)}"><xsl:value-of select="current()/@nodeName" /></a></h3> <p> <xsl:choose> <xsl:when test="current()/eventAllDay != '0'"> <xsl:value-of select="umbraco.library:FormatDateTime(current()/eventStartDateTime, 'dddd, d. MMMM yyyy')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="umbraco.library:FormatDateTime(current()/eventStartDateTime, 'dddd, d. MMMM yyyy H:mm')"/> </xsl:otherwise> </xsl:choose> </p> <!--<p><xsl:value-of select="current()/data [@alias='eventLocationAddress']"/></p>--> </div> </li> </xsl:for-each> </ul> </xsl:when> <xsl:otherwise> <p class="no_events">Der er ingen events i denne måned.</p> </xsl:otherwise> </xsl:choose> </div> </xsl:template><xsl:variable name="DisplayDate" select="Exslt.ExsltDatesAndTimes:date()"/><xsl:variable name="Year"><xsl:choose> <xsl:when test="umbraco.library:Request('year') <= 0 or string(umbraco.library:Request('year')) = ''"> <xsl:value-of select="Exslt.ExsltDatesAndTimes:year($DisplayDate)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="umbraco.library:Request('year')"/> </xsl:otherwise></xsl:choose></xsl:variable><xsl:variable name="Month"><xsl:choose> <xsl:when test="umbraco.library:Request('month') <= 0 or string(umbraco.library:Request('month')) = ''"> <xsl:value-of select="Exslt.ExsltDatesAndTimes:monthinyear($DisplayDate)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="umbraco.library:Request('month')"/> </xsl:otherwise></xsl:choose></xsl:variable><xsl:variable name="currentMonthYear" select="concat($MonthName,',',$Year)" /><xsl:variable name="MonthName"> <xsl:choose> <xsl:when test="$Month = 1">januar</xsl:when> <xsl:when test="$Month = 2">februar</xsl:when> <xsl:when test="$Month = 3">marts</xsl:when> <xsl:when test="$Month = 4">april</xsl:when> <xsl:when test="$Month = 5">maj</xsl:when> <xsl:when test="$Month = 6">juni</xsl:when> <xsl:when test="$Month = 7">juli</xsl:when> <xsl:when test="$Month = 8">august</xsl:when> <xsl:when test="$Month = 9">september</xsl:when> <xsl:when test="$Month = 10">oktober</xsl:when> <xsl:when test="$Month = 11">november</xsl:when> <xsl:when test="$Month = 12">december</xsl:when> <xsl:otherwise>ugyldig måned</xsl:otherwise> </xsl:choose></xsl:variable><xsl:variable name="NumberOfDaysInMonth"> <xsl:call-template name="DaysInMonth"> <xsl:with-param name="month" select="$Month" /> <xsl:with-param name="year" select="$Year" /> </xsl:call-template></xsl:variable><xsl:variable name="FirstDayInWeekForMonth"> <xsl:choose> <xsl:when test="$Month < 10"> <xsl:value-of select="Exslt.ExsltDatesAndTimes:dayinweek(Exslt.ExsltDatesAndTimes:date(concat($Year,'-0', $Month, '-01')))" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="Exslt.ExsltDatesAndTimes:dayinweek(Exslt.ExsltDatesAndTimes:date(concat($Year,'-', $Month, '-01')))" /> </xsl:otherwise> </xsl:choose></xsl:variable><xsl:variable name="WeeksInMonth"><xsl:value-of select="($NumberOfDaysInMonth + $FirstDayInWeekForMonth - 1) div 7" /></xsl:variable><xsl:template name="DaysInMonth"> <xsl:param name="month"><xsl:value-of select="$Month" /></xsl:param> <xsl:param name="year"><xsl:value-of select="$Year" /></xsl:param> <xsl:choose> <xsl:when test="$month = 1 or $month = 3 or $month = 5 or $month = 7 or $month = 8 or $month = 10 or $month = 12">31</xsl:when> <xsl:when test="$month=2"> <xsl:choose> <xsl:when test="$year mod 4 = 0">29</xsl:when> <xsl:otherwise>28</xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise>30</xsl:otherwise> </xsl:choose></xsl:template><xsl:template name="NextMonthLink"> <xsl:param name="currentMonth"><xsl:value-of select="$Month" /></xsl:param> <xsl:param name="currentYear"><xsl:value-of select="$Year" /></xsl:param> <xsl:choose> <xsl:when test="$currentMonth = 12"> <a class="next_month" title="Næste måned"> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)"/> <xsl:text>?year=</xsl:text> <xsl:value-of select="$currentYear + 1"/> <xsl:text>&month=1</xsl:text> </xsl:attribute> <span><xsl:text>Næste måned</xsl:text></span> </a> </xsl:when> <xsl:otherwise> <a class="next_month" title="Næste måned"> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)"/> <xsl:text>?year=</xsl:text> <xsl:value-of select="$currentYear"/> <xsl:text>&month=</xsl:text> <xsl:value-of select="$currentMonth + 1"/> </xsl:attribute> <span><xsl:text>Næste måned »</xsl:text></span> </a> </xsl:otherwise> </xsl:choose></xsl:template><xsl:template name="PreviousMonthLink"> <xsl:param name="currentMonth"><xsl:value-of select="$Month" /></xsl:param> <xsl:param name="currentYear"><xsl:value-of select="$Year" /></xsl:param> <xsl:choose> <xsl:when test="$currentMonth = 1"> <a class="previous_month" title="Forrige måned"> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)"/> <xsl:text>?year=</xsl:text> <xsl:value-of select="$currentYear - 1"/> <xsl:text>&month=12</xsl:text> </xsl:attribute> <span><xsl:text>Forrige måned</xsl:text></span> </a> </xsl:when> <xsl:otherwise> <a class="previous_month" title="Forrige måned"> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)"/> <xsl:text>?year=</xsl:text> <xsl:value-of select="$currentYear"/><xsl:text>&month=</xsl:text> <xsl:value-of select="$currentMonth - 1"/> </xsl:attribute> <span><xsl:text>« Forrige måned</xsl:text></span> </a> </xsl:otherwise> </xsl:choose></xsl:template><xsl:template name="Calendar"> <h5 class="event_cal_current"> <xsl:value-of select="$MonthName" /> <xsl:text> </xsl:text> <xsl:value-of select="$Year" /> <xsl:call-template name="PreviousMonthLink" /> <xsl:call-template name="NextMonthLink" /> </h5> <table class="sm_calendar"> <tr> <th><abbr title="Søndag">Søn</abbr></th> <th><abbr title="Mandag">Man</abbr></th> <th><abbr title="Tirsdag">Tir</abbr></th> <th><abbr title="Onsdag">Ons</abbr></th> <th><abbr title="Torsdag">Tor</abbr></th> <th><abbr title="Fredag">Fre</abbr></th> <th><abbr title="Lørdag">Lør</abbr></th> </tr> <xsl:call-template name="CalendarWeek"/> </table></xsl:template><xsl:template name="CalendarWeek"> <xsl:param name="week">1</xsl:param> <xsl:param name="day">1</xsl:param> <tr> <xsl:call-template name="CalendarDay"> <xsl:with-param name="day" select="$day" /> </xsl:call-template> </tr> <xsl:if test="$WeeksInMonth > $week"> <xsl:call-template name="CalendarWeek"> <xsl:with-param name="week" select="$week + 1" /> <xsl:with-param name="day" select="$week * 7 - ($FirstDayInWeekForMonth - 2)" /> </xsl:call-template> </xsl:if></xsl:template><xsl:template name="CalendarDay"> <xsl:param name="count">1</xsl:param> <xsl:param name="day" /> <xsl:choose> <xsl:when test="($day = 1 and $count != $FirstDayInWeekForMonth) or $day > $NumberOfDaysInMonth"> <td class="empty"><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></td> <xsl:if test="$count < 7"> <xsl:call-template name="CalendarDay"> <xsl:with-param name="count" select="$count + 1" /> <xsl:with-param name="day" select="$day" /> </xsl:call-template> </xsl:if> </xsl:when> <xsl:otherwise> <td> <xsl:variable name="currentDate" select="concat($day,'. ',$MonthName,' ',$Year)" /> <xsl:variable name="eventsToday" select="count($currentPage//* [@isDoc and name()='Event' and Exslt.ExsltStrings:lowercase($currentDate) = Exslt.ExsltStrings:lowercase(umbraco.library:FormatDateTime(./eventStartDateTime, 'd. MMMM yyyy'))])" /> <xsl:if test="$eventsToday > 0"> <xsl:attribute name="class"> <xsl:text>eventDay</xsl:text> </xsl:attribute> <div class="events_today"> <div class="tooltip"> <div class="top"><xsl:text> </xsl:text></div> <h6><xsl:value-of select="$currentDate" /></h6> Events i dag: <xsl:value-of select="$eventsToday" /> <ul class="events_today_list"> <xsl:for-each select="$currentPage//* [@isDoc and name()='Event' and Exslt.ExsltStrings:lowercase($currentDate) = Exslt.ExsltStrings:lowercase(umbraco.library:FormatDateTime(./eventStartDateTime, 'd. MMMM yyyy'))]"> <li> <a href="{umbraco.library:NiceUrl(current()/@id)}"><xsl:value-of select="current()/@nodeName" /></a> </li> </xsl:for-each> </ul> <div class="bottom"><xsl:text> </xsl:text></div> </div> </div> </xsl:if> <xsl:if test="$currentDate"> <xsl:attribute name="class"> <xsl:text>today</xsl:text> </xsl:attribute> </xsl:if> <xsl:value-of select="$day" /> </td> <xsl:if test="$count < 7"> <xsl:call-template name="CalendarDay"> <xsl:with-param name="count" select="$count + 1" /> <xsl:with-param name="day" select="$day + 1" /> </xsl:call-template> </xsl:if> </xsl:otherwise> </xsl:choose></xsl:template></xsl:stylesheet>
Ok...what happens if you do this...
<xsl:if test="umbraco.library:GetCurrentDate() = $currentDate">
<!-- your attribute stuff here--></xsl:if>
Then I get this error Extension object 'urn:umbraco.library' does not contain a matching 'GetCurrentDate' method that has 0 parameter(s).
Oops...my bad, wrote it wrong! There is no GetCurrentDate method :)
Just use the method you're writing about in the initial post - umbraco.library:CurrentDate()
Okay.. I had tried that too, but it doesn't add any class..
You can see the calendar here: http://sub.ak-security.dk/da/aktuelt/events.aspx
Hmm, what does the output from you $currentDate variable look like? I suspect that the content of the variable and the output from the CurrentDate method is not the same.
the $currentDate gives me a date on this format: 1. december 2011
but yes I don't think that it match the standard date format..the best is probably to format umbraco.library.CurrentDate() ..
I solved it with this:
<xsl:if test="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(), 'd. MMMM yyyy') = $currentDate"><xsl:attribute name="class"> <xsl:text>today</xsl:text></xsl:attribute> </xsl:if>
and now it has a class added to the current date..
Is there a way to get this code to start on a Saturday instead of a Sunday?
is working on a reply...
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.
Continue discussion
Add class for current date
Hi..
I have an event calendar where I try to add a class to the td i the table for the current date, where I have tried with:
and
but it adds the today class for all dates except the ones, where an empty class is added..
What do I need to add a class for todays date/current date..?
Bjarne
Hi Bjarne
Could you provide a bit more of the code? I would like to see more of the context if that's ok :)
/Jan
Okay, here is the full code :) It's basically the code to the event calendar in Business Website Starter Pack with some small modifications..
Bjarne
Hi Bjarne
Ok...what happens if you do this...
<xsl:if test="umbraco.library:GetCurrentDate() = $currentDate">
<!-- your attribute stuff here-->
</xsl:if>
/Jan
Then I get this error Extension object 'urn:umbraco.library' does not contain a matching 'GetCurrentDate' method that has 0 parameter(s).
Bjarne
Oops...my bad, wrote it wrong! There is no GetCurrentDate method :)
Just use the method you're writing about in the initial post - umbraco.library:CurrentDate()
/Jan
Okay.. I had tried that too, but it doesn't add any class..
You can see the calendar here: http://sub.ak-security.dk/da/aktuelt/events.aspx
Hmm, what does the output from you $currentDate variable look like? I suspect that the content of the variable and the output from the CurrentDate method is not the same.
/Jan
the $currentDate gives me a date on this format: 1. december 2011
but yes I don't think that it match the standard date format..
the best is probably to format umbraco.library.CurrentDate() ..
Bjarne
I solved it with this:
and now it has a class added to the current date..
Bjarne
Is there a way to get this code to start on a Saturday instead of a Sunday?
is working on a reply...
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.