I have lots of media files that are purposed to be downloaded. I want to archieve all the media files based on the year, then month and (in descending order).
I take that this should be done in XSLT? :-) If so, you should be able to use the <xsl:sort /> when looping through your collections. Have a look at this:
Currently I have 25 records on the $files, and sorted them according to year, month, date and then time. All of them are of year 2011 except one that is 2009.
So basically what I want is to make a group according to year. At the moment I couldn't divide the node-set according to year.
I tried to make it more usuable by modify the xslt. Now I would like to have something like
2011 (3)
--Jun (2)
--file1
--file2
--Feb (1)
--file3
2009 (1)
--Dec (1)
--file4
Basically I would like to have group by month from the nodeset that is group by year. I am getting node set grouped by year but then tried to group them further by month. but all the months are shown on both the year group.
Great - I was just about to post, but hit refresh first... :-)
Only real difference in my suggestion is to include the year in the FileByMonth key (e.g. use="substring(@createDate, 1, 7)" instead) but they both work.
Archieve media files according to creation date
Hi to All,
I have lots of media files that are purposed to be downloaded. I want to archieve all the media files based on the year, then month and (in descending order).
like
2010 (17)
--dec (5)
-- nov (12)
2009 (4)
--may (2)
--apr (2)
Hi praveity,
I take that this should be done in XSLT? :-) If so, you should be able to use the <xsl:sort /> when looping through your collections. Have a look at this:
http://our.umbraco.org/wiki/how-tos/xslt-useful-tips-and-snippets/conditional-xslt-sorting
All the best,
Bo
Hi Mortensen,,
I am already sorting the list. Here is my full xslt
Currently I have 25 records on the $files, and sorted them according to year, month, date and then time. All of them are of year 2011 except one that is 2009.
So basically what I want is to make a group according to year. At the moment I couldn't divide the node-set according to year.
e.g.
2011
--list all 2011 files [AND THEN]
2009
--list all 2009 files
Hope you got my idea :)
Hi praveity,
You'll need yourself some "grouping-fu" - here's a basic setup:
One thing I'd like to mention though: All of the sort statements in your original code can be replaced by one single sort:
No need to call the FormatDateTime() extension multiple times - the XML date format was designed to be sortable as-is.
/Chriztian
Hi Chriztian,
Thanks for the xslt, you were correct about the sorting. I have the list of all files in descending order.
My complete xslt is as follows
The result is as follows
2011 (3)
--file1
--file2
--file3
2009 (1)
--file4
I tried to make it more usuable by modify the xslt. Now I would like to have something like
2011 (3)
--Jun (2)
--file1
--file2
--Feb (1)
--file3
2009 (1)
--Dec (1)
--file4
Basically I would like to have group by month from the nodeset that is group by year. I am getting node set grouped by year but then tried to group them further by month. but all the months are shown on both the year group.
2011 (3)
May (1)
Jul (1)
Oct (1)
2009 (1)
May (1)
Jul (1)
Oct (1)
Finally, I succeeded in having the expected results. Here is the working xslt, hope this could help other umbraco developers.. cheers
Great - I was just about to post, but hit refresh first... :-)
Only real difference in my suggestion is to include the year in the FileByMonth key (e.g. use="substring(@createDate, 1, 7)" instead) but they both work.
/Chriztian
Thanks for your dedication and help.
I tried your suggestion as well yes it does work :)
is working on a reply...