Developer forum

Forum » Templates » Sort navigation xslt

Sort navigation xslt

Per Ljung
Reply
Hi!

Is there way to sort each level in the menu code (xslt-template)? I think I've only have managed to sort the groups alltogether, not each level in isolation.

Is there a way to accomplish this?

Best regards,
P

Replies

 
Nicolai Høeg Pedersen
Reply
You can do it in your xslt using xslt sort:
http://www.w3schools.com/xsl/el_sort.asp


 
Per Ljung
Reply
You can do it in your xslt using xslt sort:
http://www.w3schools.com/xsl/el_sort.asp



Yes, I know about the xsl:sort function. But not how to use it in the Ecom Navigation xslt-file. The xslt-file uses "depth-first"-logic to recursivly write out the menu items.
 

menu 1, level 1
    menuitem 1, level 2
    menuitem 2, level 2
    menuitem 3, level 2

menu 2, level 1
    menuitem 1, level 2
    menitem 2, level 2
 


So, first it reads menu 1 down to menuitem 3 at level 2, then up till level 1 again and reads menu 2 down to the bottom.
 

I would need an example how to use the xsl:sort, it's easier to use it in a for-each-loop than in a recurisive algorithm.
 

Best regards,
Per

 
Nicolai Høeg Pedersen
Reply
That depends on your node selector:
http://www.w3schools.com/xpath/xpath_syntax.asp


 

You must be logged in to post in the forum