tag:help-archives.hannonhill.com,2010-02-09:/discussions/xslt-formats/2078-script-repeats-resultsCascade CMS: Discussion 2015-09-22T21:06:00Ztag:help-archives.hannonhill.com,2010-02-09:Comment/277126232013-07-10T19:26:40Z2013-07-10T19:26:40ZScript repeats results<div><p>Hi Shruti,</p>
<p>When you have a moment, please provide the XML output of Index
Block that is being applied to this Format. This will help me test
your Format locally.</p>
<p>To do this, modify the following:</p>
<pre>
<code><xsl:template match="/system-index-block">
<xsl:apply-templates select="system-page[@current='true' and name='index']"/>
<xsl:apply-templates select="system-folder"/>
</xsl:template></code>
</pre>
<p>To:</p>
<pre>
<code><xsl:template match="/system-index-block">
<xsl:copy-of select="." />
</xsl:template></code>
</pre>
<p>This should dump the Index Block's XML to your Page's source,
which can be found by viewing the source code of the preview pane.
Specifically, look for the XML beginning with
<code><system-index-block></code> and ending with
<code></system-index-block></code>.</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/277126232013-07-10T20:42:33Z2015-09-22T21:06:00ZScript repeats results<div><p>I am not sure if I understood you correctly. After replacing the
part of code, I went to preview and clcked on xml to see this:</p>
<pre>
<code><system-index-block current-time="1373488831256" name="breadcrumbs" type="folder"><system-folder id="c4aa6b71c0a8015600b10d845ca0a527"><name>/</name><path>//</path><site>GWC</site><link>site://GWC/</link><system-folder current="true" id="c4ad0417c0a8015600b10d84b4fd0033"><name>features</name><display-name>Features</display-name><path>/features</path><site>GWC</site><link>site://GWC/features</link><system-page current="true" id="c4bbe62ec0a8015600b10d845a20dab1"><name>index</name><title>Featured Stories</title><display-name>Featured Stories</display-name><path>/features/index</path><site>GWC</site><link>site://GWC/features/index</link><dynamic-metadata><name>left-nav</name><value>Yes</value></dynamic-metadata><dynamic-metadata><name>keywords</name></dynamic-metadata></system-page></system-folder></system-folder></system-index-block></code>
</pre>
<p>Is this what you need?</p></div>ssargamtag:help-archives.hannonhill.com,2010-02-09:Comment/277126232013-07-11T12:25:10Z2013-07-11T12:25:10ZScript repeats results<div><p>Hm, this is definitely close; however, I am not seeing any Pages
other than the Features index page. The Index Block is called
<strong>breadcrumbs</strong>, could this have been an output of the
wrong Region/Format by chance?</p>
<p>When you have a moment, would you be able to take a screenshot
of the Edit screen for the Index Block you are applying to this
Format? This should help me set things up locally for testing.</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/277126232013-07-11T13:32:35Z2015-09-22T21:06:00ZScript repeats results<div><p>Hi Ryan;</p>
<p>Thank you so much for your help. I am attaching the screenshot
of the index block, edit screen</p></div>ssargamtag:help-archives.hannonhill.com,2010-02-09:Comment/277126232013-07-11T16:47:32Z2015-09-22T21:06:00ZScript repeats results<div><p>I am really confused at this point, did you happen to find
something?</p>
<p>Much appreciate your help.</p></div>ssargamtag:help-archives.hannonhill.com,2010-02-09:Comment/277126232013-07-11T18:14:29Z2013-07-11T18:14:29ZScript repeats results<div><p>Hi Shruti,</p>
<p>Although I was not yet able to group by both year and month,
here is a Format that should group your Pages by year and sort them
by their start-date. Perhaps this will give a decent starting
point.</p>
<pre>
<code><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="date long xalan" extension-element-prefixes="date-converter" version="1.0" xmlns:date="http://xml.apache.org/xalan/java/java.util.Date" xmlns:date-converter="http://www.hannonhill.com/dateConverter/1.0/" xmlns:long="http://xml.apache.org/xalan/java/java.lang.Long" xmlns:xalan="http://xml.apache.org/xalan">
<xsl:output indent="yes" method="xml"/>
<xsl:key match="start-date" name="groupbymonth" use="date-converter:convertMonth(number(.))"/>
<xsl:key match="start-date" name="groupbyyear" use="date-converter:convertYear(number(.))"/>
<xsl:template match="/system-index-block">
<xsl:for-each select="//system-page/start-date[count(. | key('groupbyyear', date-converter:convertYear(number(.)))[1]) = 1]">
<xsl:sort order="descending" select="."/>
<xsl:variable name="currentYear" select="date-converter:convertYear(number(.))"/>
<dl>
<dt><xsl:value-of select="$currentYear"/></dt>
<xsl:apply-templates select="../../system-page[date-converter:convertYear(number(start-date)) = $currentYear]">
<xsl:sort order="descending" select="start-date"/>
</xsl:apply-templates>
</dl>
</xsl:for-each>
</xsl:template>
<xsl:template match="system-page">
<xsl:variable name="startDate" select="start-date"/>
<xsl:variable name="currentDate" select="date-converter:convertDate(number($startDate))"/>
<xsl:variable name="currentMonth" select="date-converter:convertMonth(number($startDate))"/>
<xsl:variable name="currentYear" select="date-converter:convertYear(number($startDate))"/>
<dd>
<xsl:value-of select="$currentMonth"/>/<xsl:value-of select="$currentDate"/>/<xsl:value-of select="$currentYear"/>
<a href="{path}" style="text-decoration:none;">
<xsl:choose>
<xsl:when test="system-data-structure/headline != ''">
<xsl:value-of select="system-data-structure/headline"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="title"/>
</xsl:otherwise>
</xsl:choose>
</a>
</dd>
</xsl:template>
<!-- Xalan component for date conversion from CMS date format to RSS 2.0 pubDate format -->
<xalan:component functions="convertDate" prefix="date-converter">
<xalan:script lang="javascript">
<!-- display the date and time in format "m/d/yyyy h:mm AM|PM" -->
function convertMonth(date)
{
var months = new Array(13);
months[0] = "1";
months[1] = "2";
months[2] = "3";
months[3] = "4";
months[4] = "5";
months[5] = "6";
months[6] = "7";
months[7] = "8";
months[8] = "9";
months[9] = "10";
months[10] = "11";
months[11] = "12";
var d = new Date(date); // Splits date into components
return months[d.getMonth()];
}
function convertDate(date)
{
var d = new Date(date); // Splits date into components
return d.getDate();
}
function convertYear(date)
{
var d = new Date(date); // Splits date into components
return d.getFullYear();
}
</xalan:script>
</xalan:component>
</xsl:stylesheet></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/277126232013-07-11T19:42:20Z2015-09-22T21:06:00ZScript repeats results<div><p>Thanks Ryan, this is is perfect.</p>
<p>Thanks for your help! :)</p></div>ssargamtag:help-archives.hannonhill.com,2010-02-09:Comment/277126232013-07-11T20:07:23Z2013-07-11T20:07:23ZScript repeats results<div><p>Thank you for the follow up, I am 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