将umbraco.library:CurrentDate()与datepicker字段进行比较

时间:2013-08-13 12:58:12

标签: xslt datepicker umbraco

我遇到以下问题。我想将两个日期选择器与时间字段与 umbraco.library:CurrentDate()进行比较,以便我可以制作一个XSLT,根据时间的不同,它可以执行三种不同的操作与我在两个日期选择器时间中输入的时间相比较。

目前,我有这个:

<xsl:variable name="currenttime" select="umbraco.library:CurrentDate()" />
<xsl:choose>
    <xsl:when test="$currenttime &lt; dateEvent">
        <a href="{umbraco.library:NiceUrl(@id)}">Event is not yet live</a>
    </xsl:when>
    <xsl:when test="$currenttime &gt; dateEvent and $currenttime &lt; dateEventpassed">
        <a href="{umbraco.library:NiceUrl(@id)}/live.aspx">Event is live</a>
    </xsl:when>
    <xsl:otherwise>
        <a href="{umbraco.library:NiceUrl(@id)}/different.aspx">Event has passed</a>
    </xsl:otherwise>

但它似乎不起作用。这可能与日期格式的方式有关吗?我甚至不接近成为Umbraco的专家所以非常感谢任何帮助

2 个答案:

答案 0 :(得分:0)

您没有正确引用dateEventdateEventpassed。如果这些是变量,则需要向其添加$

Umbraco library functions来比较日期。

您的代码应该是这样的:

<xsl:variable name="currenttime" select="umbraco.library:CurrentDate()" />
<xsl:choose>
    <xsl:when test="umbraco.library.DateGreaterThan($dateEvent, $currenttime)">
        <a href="{umbraco.library:NiceUrl(@id)}">Event is not yet live</a>
    </xsl:when>
    <xsl:when test="umbraco.library.DateGreaterThan($currenttime, $dateEvent) and   umbraco.library.DateGreaterThanOrEqual($dateEventpassed, $currenttime)">
        <a href="{umbraco.library:NiceUrl(@id)}/live.aspx">Event is live</a>
    </xsl:when>
    <xsl:otherwise>
        <a href="{umbraco.library:NiceUrl(@id)}/different.aspx">Event has passed</a>
    </xsl:otherwise>

答案 1 :(得分:0)

我终于想出了这个结果:

                <xsl:variable name="huidigetijd" select="umbraco.library:CurrentDate()" />  
                <xsl:choose>
                    <xsl:when test="umbraco.library:DateGreaterThan(dateEvent, $huidigetijd)">
                    <a href="{umbraco.library:NiceUrl(@id)}">Event is not yet live</a>
                    </xsl:when>
                    <xsl:when test="umbraco.library:DateGreaterThan($huidigetijd, dateEvent) and umbraco.library:DateGreaterThan(dateEventpassed, $huidigetijd)">
                        <a href="{umbraco.library:NiceUrl(@id)}/live.aspx">Event is live</a>
                    </xsl:when>
                    <xsl:otherwise>
                    <a href="{umbraco.library:NiceUrl(@id)}/different.aspx">Event has passed</a>
                    </xsl:otherwise>
                </xsl:choose>

为Ollie P提供可靠的答案。