I have been trying to create a grouping of events by using the Muncheun method. It's been producing varying results (see the this post). So, I thought, forget about that method, i'll just use a standard variable grouping by looking ar preceding-sibling. Unfortunately, that doesn't work either since I am trynig to group by a date field and simply using masks to format the data. Like this:
In this example I'm using a formatted date string as the key to group from, but you have any option. If you cannot work it out, I can try to adapt the method to your purpose - just let me know. Now I have to take the kids to kindergarden...
I can not test if this works for you, but the syntax for doing what you want is wrong - you need to specify the element name after an axis, so to correct the line you're having trouble with, do:
@Tommy, the strange this is I CAN get it to work in dev but not production. So weird, and I actually use that grouping on other macros a swell (by month/year). I've abandoned this for now as I have to move on. I'll dig in deeper using this method at later time to see if I can figure it out.
@Chriztian, thanks! I think that is exactly what my problem is. I'll give it a test and let you know. Appreciate the insight!
Not meaning to hijaak this thread, but I don't see that there was a resolution. Below is my latest attempt. The code works great for content below currentpage but fails for content in sibling nodes. I am getting every node for the entire site.
I am trying to categorize or group my press releases based on the year of publishing.When i am using key 'year' (i.e; using formatdatetime )the results are not coming. and when using key 'uniquedate' duplicate years are appearing,can anyone let me know what is the error?
Grouping nodes by Month
Hi Community,
I have been trying to create a grouping of events by using the Muncheun method. It's been producing varying results (see the this post). So, I thought, forget about that method, i'll just use a standard variable grouping by looking ar preceding-sibling. Unfortunately, that doesn't work either since I am trynig to group by a date field and simply using masks to format the data. Like this:
<xsl:for-each select="$eventNodes"> <xsl:sort select="data [@alias='eventStartDate']"/> <xsl:variable name="lastMonth" select="umbraco.library:FormatDateTime(data [@alias='eventStartDate'],'MMMM')" /> !!!!! <xsl:if test="not(preceding-sibling::umbraco.library:FormatDateTime(data [@alias='eventStartDate'],'MMMM')=$lastMonth)"> <h2 class="dotted"> <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias='eventStartDate'],'MMMM - yyyy')" /> </h2> <div class="ctr-events"> <ul> <xsl:for-each select="$eventNodes[umbraco.library:FormatDateTime(data [@alias='eventStartDate'],'MMMM')=$lastMonth]"> <xsl:sort select="data [@alias='eventStartDate']"/> <li> <div class="event_date_cal"> <span class="event_date_cal_day"> <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias=$groupByAlias], 'ddd')"/> </span> <span class="event_date_cal_month"> <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias=$groupByAlias], ' d')"/> </span> </div> <div class="info"> <div class="title"> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </div> <span class="location"> Location: <span class="bold"> <xsl:value-of select="data [@alias = 'eventPrimaryLocation']"/> </span> </span> </div> <div class="clear"><xsl:text> </xsl:text></div> </li> </xsl:for-each> </ul> </div> </xsl:if> </xsl:for-each>!!!! = not working
The grouping doesn't work since preceding-sibling::umbraco.library.... doesn't work syntactically.
So, my question is, has anyone successfully grouped nodes by month/year using XSLT? If so, would you mind sharing it here?
Thanks!
-- Nik
Hi Nik, I'm using grouping by date by the Munchean method on a couple of sites. My approach is this:
http://blackpoint.dk/umbraco-workbench.aspx?Snippet=/umbraco-workbench/xslt/grouping--distinct-values.aspx
In this example I'm using a formatted date string as the key to group from, but you have any option. If you cannot work it out, I can try to adapt the method to your purpose - just let me know. Now I have to take the kids to kindergarden...
>Tommy
Hi Nik,
I can not test if this works for you, but the syntax for doing what you want is wrong - you need to specify the element name after an axis, so to correct the line you're having trouble with, do:
("If there's not a preceding sibling named node, having ..... ")
/Chriztian
Hi,
@Tommy, the strange this is I CAN get it to work in dev but not production. So weird, and I actually use that grouping on other macros a swell (by month/year). I've abandoned this for now as I have to move on. I'll dig in deeper using this method at later time to see if I can figure it out.
@Chriztian, thanks! I think that is exactly what my problem is. I'll give it a test and let you know. Appreciate the insight!
Best,
Nik
Not meaning to hijaak this thread, but I don't see that there was a resolution. Below is my latest attempt. The code works great for content below currentpage but fails for content in sibling nodes. I am getting every node for the entire site.
Hi all,
I am trying to categorize or group my press releases based on the year of publishing.When i am using key 'year' (i.e; using formatdatetime )the results are not coming. and when using key 'uniquedate' duplicate years are appearing,can anyone let me know what is the error?
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:key name="uniqueDate" match="PressRelease" use="pressPublishDate"/>
<xsl:key name="year" match="PressRelease" use="umbraco.library:FormatDateTime(pressPublishDate,'YYYY')"/>
<xsl:key name="kNewsByY" match="PressRelease" use="Exslt.ExsltDatesAndTimes:year(pressPublishDate)" />
<xsl:template match="/">
<xsl:for-each select="$currentPage/child::*[generate-id() = generate-id(key('year', umbraco.library:FormatDateTime(pressPublishDate,'YYYY'))[1])]">
<xsl:value-of select="substring(pressPublishDate, 1, 4)"/>
<br/>
</xsl:for-each>
<div class="subnavTabs clearfix" id="subNavTabs">
<ul>
<xsl:apply-templates select="$currentPage/child::*[generate-id() = generate-id(key('uniqueDate', pressPublishDate)[1])]" mode="PressRelease">
<xsl:sort select="pressPublishDate" order="descending" />
</xsl:apply-templates>
</ul>
</div>
<!--<xsl:for-each select="$currentPage/child::*">
<xsl:value-of select="pressPublishDate"/>
<xsl:value-of select="substring(pressPublishDate, 1,4)"/>
<br/>
</xsl:for-each>-->
</xsl:template>
<xsl:template match="PressRelease" mode="PressRelease">
<xsl:variable name="PublishDate">
<xsl:value-of select="substring(pressPublishDate, 1, 4)" />
</xsl:variable>
<xsl:variable name="DivId" select="concat('Div',$PublishDate)" />
<li>
<xsl:attribute name="id">
<xsl:if test="$PublishDate = '2010'">
<xsl:text>current</xsl:text>
</xsl:if>
</xsl:attribute>
<a href="javascript:Toggle();">
<xsl:attribute name="onclick">
<xsl:value-of select="concat('ShowTab(',$DivId,',this);')"/>
</xsl:attribute>
<xsl:value-of select="$PublishDate"/>
</a>
</li>
</xsl:template>
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.