5450 Posts in 1672 Topics by 1197 members
|Go to End|
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 $default_sort, 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.
13 October 2010 at 5:26pm
I have the same requirement too. Currently I am doing this:
SiteTree::$default_sort = 'IF("SiteTree"."ClassName" = \'MyPage\', LOWER("SiteTree"."Title"), "SiteTree"."Sort")';
This will sort MyPage pages using Title and the rest of the pages using Sort. If anyone has a better solution, do share. Thanks
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.
Hope that helps someone.
|Go to Top|