I have an Umbraco V4.0.3 website and within it I have a news section that is using Autofolders 2.2 to create the following structure based on a date picker document property called weekEnding:
On my news page I want the news items to be displayed as follows but I am struggling to get started with the XSLT, I have created lots of news lists in the past using XSLT but nothing like this so wondered if someone could point me in the right direction. Many thanks. I want it to look as follows:
Just to update for anyone who has a similar issue (I like to think I sometimes give back to the Umbraco community as well as pestering everyone with questions!), I have made this work with the following XSLT:
<xsl:param name="currentPage"/>
<!-- This is the key definitions using the year and week ending (day) of the the node weekEnding property - all nodes with the same week ending date get same week-key id, all nodes with the same year get the same year-key id --> <xsl:key name="years" match="node" use="umbraco.library:FormatDateTime(data[@alias='weekEnding'], 'yyyy')"/> <xsl:key name="week" match="node" use="umbraco.library:FormatDateTime(data[@alias='weekEnding'], 'yyyy-MM-dd')"/>
<xsl:template match="/"> <ul> <!-- Iterate over all nodes with a year-id similar to the first in every group --> <xsl:for-each select="$currentPage//node [ (generate-id() = generate-id(key('years', Exslt.ExsltDatesAndTimes:year(data[@alias='weekEnding']))[1]))]"> <xsl:sort select="data[@alias='weekEnding']" order="descending" /> <li> <ul> <xsl:variable name="week" select="key('years', Exslt.ExsltDatesAndTimes:year(data[@alias='weekEnding']))" /> <!-- Iterate over all nodes with a week-id similar to the first in every group --> <xsl:for-each select="$week[generate-id() = generate-id(key('week',umbraco.library:FormatDateTime(data[@alias='weekEnding'], 'yyyy-MM-dd'))[1])]"> <xsl:sort select="data[@alias='weekEnding']" order="descending" /> <li><h2>Week ending <xsl:value-of select="umbraco.library:FormatDateTime(data[@alias='weekEnding'], 'dd MMMM yyyy')"/></h2> <ul> <!-- Iterate over all nodes in a group, i.e. with the same week-key --> <xsl:for-each select="key('week',umbraco.library:FormatDateTime(data[@alias='weekEnding'], 'yyyy-MM-dd'))"> <xsl:sort select="data[@alias='weekEnding']" order="descending" /> <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="data [@alias = 'articletitle']" /></a> </li> </xsl:for-each> </ul> </li> </xsl:for-each> </ul> </li> </xsl:for-each> </ul> </xsl:template>
List news items by the folder they are in
Hi,
I have an Umbraco V4.0.3 website and within it I have a news section that is using Autofolders 2.2 to create the following structure based on a date picker document property called weekEnding:
News Section
- 2010
- April
-02
- Article 1
- Article 2
- March
-29
- Article 3
- Article 4
On my news page I want the news items to be displayed as follows but I am struggling to get started with the XSLT, I have created lots of news lists in the past using XSLT but nothing like this so wondered if someone could point me in the right direction. Many thanks. I want it to look as follows:
News
Week ending 2nd April 2010
Article 1
Article 2
Week ending 29th March 2010
Article 3
Article 4
Hi again
This xslt is a start, without solving your whole problem (that's the point!)
It breaks up month and years using datefolders. Your only challenge left would be to get the day from the final level of datefolders and print that,
Hope this helps,
Dan
Hi Dan,
Thanks for the response I will take a look at that (although I am having a bit of an issue with Autofolders at the moment but that's another post!). I was reading the following article which I thought was quite interesting http://blackpoint.dk/umbraco-workbench.aspx?Snippet=/umbraco-workbench/xslt/grouping--distinct-values.aspx and wondered if maybe it would do the job.
Just to update for anyone who has a similar issue (I like to think I sometimes give back to the Umbraco community as well as pestering everyone with questions!), I have made this work with the following XSLT:
is working on a reply...