How to fix alphabetic sorting of pages in EPiServer

I recently got the question how to fix the incorrect alphabetic sorting of child pages in EPiServer. It is usually Scandinavian users complaining that Å, Ä and Ö are sorted together with A and O instead of being at the end of the list.

Sort order: Alphabetical

When you specify the sort order of child pages your selection is stored in the database (tblPage.PeerOrderRule) and is shared for all language branches.
When you use GetChildren() it calls a stored procedure called netPageLinkList that returns the children ordered differently depending on the selection. Sorting is done in the database.

Easy Solution To Child Page Sort Order in EPiServer

1) Easiest way to fix sorting is to change the Collation order of the Name column in the tblPageLanguage table.

image

different sort order depending on the current culture

The easy solution only allows one common sort order for the entire database and that might not be good enough for multi lingual sites.
2) You can solve this for the whole site by hooking the event DataFactory.FinishedLoadingChildren and resorting the pages. Remember that this event is called every time you call GetChildren() and the result is not cached.
3) Another way is to solve it locally is to use the FilterSort class on you PageDataCollection or setting the SortOrder property on you PageList.
Bookmark and Share

Tags: , , , , , , , ,

  1. Fredrik Haglund’s avatar

    Oups!

    To quick to blog about the solution. There are side-effects that stops other stored procedures from working… Will investigate and get back to you!

    Reply

  2. Marcus Andersson’s avatar

    Hej!

    Har du koll på om det går att ställa in så att sidtyper, i admin-läge, alltid sorteras alfabetiskt och inte efter index?

    När jag väljer “Till adminläge” och sen fliken “Sidtyp” sorteras sidtyperna efter index. Är irriterande att varje gång behöva klicka på “Sortera alfabetiskt”.

    Kör för närvarande EPiServer CMS 5.2.375.133.

    Reply

    1. Fredrik Haglund’s avatar

      Nope, det kräver att du patchar EPiServer-filer. Inte omöjligt men lite bökigt att underhålla…

      Reply