11 August 2010 at 8:58pm
(Last edited: 11 August 2010 9:00pm),
Is it possible to change the sort order of certain objects in the SiteTree? There is [url=http://api.silverstripe.com/2.4/cms/SiteTree.html#var$default_sort]$default_sort[/url], but when set for own SiteTree objects that one has no effect for the page tree displayed in admin view.
All I got to work was changing the sort order of the whole tree structure by putting
SiteTree::$default_sort = 'Title';
in _config.inc.php. Though I want to sort some objects alphabetically, some by date and some by the default "Sort" field.
24 November 2010 at 10:43am
(Last edited: 24 November 2010 10:44am),
In case someone else is looking for answers here, i thought i'd add a little work around that I found helpful.
If you want to sort your pages once but still be able to drag and drop pages to change the order:
1) Add the code Timon added
2) Go into the backend.
3) Tick 'Drag and Drop reordering'
4) Change the order of one page, change it back.
5) Publish page.
6) Bingo. Your pages are now sorted by Title or whatever you set it to.
7) Remove Timons code.