Im making a "News"-page at my website and would like to extract the latest news with xslt, and order them by date. How can I do that? I've tried to do like this:
You could achieve this by making use of OrderBy and Take. Where you will only display 10 news items and make a sorting out of it.
for e.g
foreach(dynamic news in newsFolder.Children.OrderBy("createDate descending").Take(10)){ @news.Name // here am making use of createDate but you can also add a date picker property }
Sorting output by date
Hi all!
Im making a "News"-page at my website and would like to extract the latest news with xslt, and order them by date. How can I do that?
I've tried to do like this:
<xsl:for-each select="umbraco.library:GetXmlNodeById($source)/node [string(data [@alias='umbracoNaviHide']) != '1'] [position() < last() - number($count)]">
Where $source is my newsarchive and $count is the number of latest news to pull out.
/Kristian
The sorting can simply be done by doing an xsl:sort right below your for-each (it has to be the first thing after the for-each statement.
A full example, the XSLT for a list of my latest blog posts looks like this:
Thanks Sebastiaan, that solved it :)
hi all,
how to get top 10 news by using date and year (without considering date) in razor
Hi Siva,
You could achieve this by making use of OrderBy and Take. Where you will only display 10 news items and make a sorting out of it.
for e.g
is working on a reply...