A sort needs to go inside the for-each loop, so find that and pop the sort just after the for-each loop opens. Also see http://www.w3schools.com/xsl/el_sort.asp
If you want to customize sorting, take a look at the sorting method in Warren Buckley's CWS.
In short: you can edit your own document types or macro to include the properties "sortBy" and "sortOrder". To make it easier for later use, you can add two custom datatypes called "Sort By List" and "Sort Order List"
Add the following values to "Sort By List": sortOrder, createDate, updateDate. Add the following values to "Sort Order List": ascending, descending.
Now you have a datatype you can use in your document types. I have these properties added to my document types that has a lot of subnodes under it. In my XSLT, I then look for these properties and list the subnodes accordingly.
In your XSLT, add this at the top of your template:
Basic sort/orderby
Total xlst-n00b and first umbraco-project.
Im using the CWS starter kit, and need to change the order of items displayed in SubNavi.xslt
I believe the line in question, that needs to be altered is this:
<xsl:variable name="rootTextpageNode" select="$currentPage/ancestor-or-self::node [@level = 2 and @nodeTypeAlias = 'CWS_Textpage']" />
How can I put a sort/orderby in there, so items with newer createdDate are displayed first?
Hi There
A sort needs to go inside the for-each loop, so find that and pop the sort just after the for-each loop opens. Also see http://www.w3schools.com/xsl/el_sort.asp
Dan
Ha, I can get karma here AND on stack overflow now ;-)
As said on SO:
You can do a sort in the first line after a for-each, like so:
If you want to customize sorting, take a look at the sorting method in Warren Buckley's CWS.
In short: you can edit your own document types or macro to include the properties "sortBy" and "sortOrder".
To make it easier for later use, you can add two custom datatypes called "Sort By List" and "Sort Order List"
Add the following values to "Sort By List": sortOrder, createDate, updateDate.
Add the following values to "Sort Order List": ascending, descending.
Now you have a datatype you can use in your document types. I have these properties added to my document types that has a lot of subnodes under it. In my XSLT, I then look for these properties and list the subnodes accordingly.
In your XSLT, add this at the top of your template:
Then, directly under your for-each, add the following:
Hope this helps!
is working on a reply...