tag:help-archives.hannonhill.com,2010-02-09:/discussions/xslt-formats/835-date-time-formatCascade CMS: Discussion 2013-08-19T21:29:13Ztag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-10T11:57:21Z2013-05-10T11:57:21ZDate Time Format<div><p>Please ignore this. I figured this one out. :-)</p>
<p>Akbar</p></div>aehsantag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-10T13:00:53Z2013-05-10T13:00:53ZDate Time Format<div><p>Hi,</p>
<p>What you can help me figure out is how I can limit the display
of seminars/events using XSLT to events/seminars that are being
held either today or in future. I do not want past events displayed
on the page.</p>
<p>I understand I will need to build an index block for the
events/seminars directory. In short, I am looking for something
like this:<br>
if event_date >= today's date<br>
Then Display events.</p>
<p>Thanks,</p>
<p>Akbar</p></div>aehsantag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-10T18:07:57Z2013-05-10T18:07:57ZDate Time Format<div><p>Hi Akbar,</p>
<p>Glad to hear you were able to figure out the date issue.</p>
<p>To limit the events by current or future, you can use the
<strong>current-time</strong> attribute that is present within the
<strong>system-data-structure</strong> tag and compare it to your
Event's metadata or structure data field.</p>
<p>For example, let's assume you are using a date field called
<strong>event-start</strong> within your Event's Data Definition
and have a Content Type Index Block for your Events, consider the
following snippet:</p>
<pre>
<code><xsl:template match="/system-index-block">
<xsl:variable name="currDate" select="@current-time" />
<!-- loop through events sarting on or after the current date -->
<xsl:apply-templates select="system-page[system-data-structure/event-start >= $currDate]"/>
<!-- optionally, you can sort by this date if you need to order them -->
<!--
<xsl:apply-templates select="system-page[system-data-structure/event-start >= $currDate]">
<xsl:sort select="system-data-structure/event-start" data-type="number" order="descending" />
</xsl:apply-templates>
-->
</xsl:template>
<xsl:template match="system-page">
<!-- output your event -->
</xsl:template></code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-10T18:49:13Z2013-05-10T18:49:13ZDate Time Format<div><p>Hi Ryan,</p>
<p>Here is the XSLT I created:</p>
<p><br>
<!-- Match on the root system-index-block XML node --> =
$currDate]"> <a href=
"/xsl:apply-templates">/xsl:apply-templates</a> <a href=
"/xsl:template">/xsl:template</a></p>
<pre>
<code><!-- Match on the system-page XML node -->
<xsl:template match="system-page">
<xsl:apply-templates select="system-data-structure"/>
</xsl:template>
<!-- Match on the system-data-structure XML node -->
<xsl:template match="system-data-structure">
<!-- XHTML code for the region -->
<h3><xsl:value-of select="display-name"/></h3>
</xsl:template></code>
</pre>
<p><a href="/xsl:stylesheet">/xsl:stylesheet</a></p>
<p>Just trying to get display name for now. If it works, I will try
other fields I want.</p>
<p>However, it outputs nothing.</p>
<p>Akbar.</p></div>aehsantag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-10T19:57:27Z2013-05-10T19:57:27ZDate Time Format<div><p>Hi Akbar,</p>
<p>Is the <strong>display-name</strong> field a part of the Page's
Data Definition, or is this meant to be one of the Metadata fields?
If it is a Metadata Field, try the following:</p>
<pre>
<code><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Match on the root system-index-block XML node -->
<xsl:template match="/system-index-block">
<xsl:variable name="currDate" select="@current-time"/>
<xsl:apply-templates select="system-page[system-data-structure/event-start >= $currDate]">
<xsl:sort data-type="number" order="descending" select="system-data-structure/event-start"/>
</xsl:apply-templates>
</xsl:template>
<!-- Match on the system-page XML node -->
<xsl:template match="system-page">
<h3><xsl:value-of select="display-name"/></h3>
</xsl:template>
</xsl:stylesheet></code>
</pre>
<p>Note: for the <code><xsl:apply-templates
select="system-page.../></code> at the top, you want to do one
or the other so I removed removed the first one and left the
sorting version.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-10T20:06:10Z2013-05-10T20:06:10ZDate Time Format<div><p>Hi Ryan,<br>
I have tried it that way. It still does not work. Here is the code
as of right now:<br>
<br>
<!-- Match on the root system-index-block XML node --> =
$currDate]"> <a href=
"/xsl:apply-templates">/xsl:apply-templates</a> <a href=
"/xsl:template">/xsl:template</a></p>
<pre>
<code><xsl:template match="system-page">
<h3><xsl:value-of select="body-title"/></h3>
<h3><xsl:value-of select="display-name"/></h3>
</xsl:template></code>
</pre>
<p><a href="/xsl:stylesheet">/xsl:stylesheet</a></p>
<p>I am so sorry to be asking you for so much. But, hopefully,
after this, I will get better.</p>
<p>Akbar</p></div>aehsantag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-10T20:47:59Z2013-05-10T20:47:59ZDate Time Format<div><p>Hi Akbar,</p>
<p>Not a problem at all.</p>
<p>For your <code><xsl:template match="system-page"></code>
template, if you are pulling content that is generated from a Data
Definition, you will need to add
<strong>system-data-structure</strong> to the front of the XPath,
if it is Metadata you do not. I suspect you may need to tweak your
value-of statements a bit. In other words, your XPath needs to
correlate with the structure of your XML.</p>
<p>Also, as I mentioned previously, you do not need to call
<code><xsl:apply-templates select="system-page.../></code>
twice within your first template, this wil essentially loop through
all Pages twice. I would use the second one, which sorts your
events by the date.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-13T13:21:33Z2013-05-13T13:21:33ZDate Time Format<div><p>Hi Ryan,</p>
<p>I modified my XSLT format unsuccessfully. I am not sure what I
am doing wrong:</p>
<p><br>
<!-- Match on the root system-index-block XML node --></p>
<pre>
<code> <xsl:variable name="currDate" select="@current-time"/>
<xsl:apply-templates select="system-page[system-data-structure/date >= $currDate]">
<xsl:sort data-type="number" order="descending" select="system-data-structure/date"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="system-page">
<h3><system-page-title/></h3>
<h3><xsl:value-of select="system-data-structure/events/event-title"/></h3>
<h3><xsl:value-of select="display-name"/></h3>
</xsl:template></code>
</pre>
<p><a href="/xsl:stylesheet">/xsl:stylesheet</a></p>
<p>I am including the XML generated by my index block and also the
XML from my data definitions. I am not sure what else I could send
you that will help you help me.</p>
<p>Thanks,</p>
<p>Akbar</p></div>aehsantag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-13T13:29:37Z2013-05-13T13:29:37ZDate Time Format<div><p>Hi Akbar,</p>
<p>It looks like the XPath within your
<code><xsl:apply-templates></code> needed to be adjusted
slightly. Based on your XML, you want to change:</p>
<p><code>system-data-structure/date</code></p>
<p>to</p>
<p><code>system-data-structure/events/date</code></p>
<p>Please try the following Format and let me know how it works out
for you:</p>
<pre>
<code><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Match on the root system-index-block XML node -->
<xsl:template match="/system-index-block">
<xsl:variable name="currDate" select="@current-time"/>
<xsl:apply-templates select="system-page[system-data-structure/events/date >= $currDate]">
<xsl:sort data-type="number" order="descending" select="system-data-structure/date"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="system-page">
<h3><xsl:value-of select="system-data-structure/events/event-title"/></h3>
<h3><xsl:value-of select="display-name"/></h3>
</xsl:template>
</xsl:stylesheet></code>
</pre>
<p>Note: the <code><system-page-title /></code> tag is not
applicable within Formats, so I went ahead and removed the tag from
the Format.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-13T13:58:04Z2013-05-13T13:58:04ZDate Time Format<div><p>Hi Ryan,</p>
<p>Thanks. That worked. So, it seems, if there is one error in
XSLT, everything blows up.</p>
<p>I will continue finishing this. Thanks for your help and
patience.</p>
<p>Akbar</p></div>aehsantag:help-archives.hannonhill.com,2010-02-09:Comment/267745542013-05-13T14:11:41Z2013-05-13T14:11:41ZDate Time Format<div><p>Not a problem at all, Akbar. Glad to hear that did the
trick.</p>
<p>I'm going to go ahead and close this discussion, please feel
free to comment or reply to re-open if you have any additional
questions.</p>
<p>Have a great day!</p></div>Ryan Griffith