Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

Sorting CMS SiteTree


Reply


4 Posts   1613 Views

Avatar
Miroke

Community Member, 9 Posts

13 January 2011 at 4:37am

I searched all Forum but couldn't find this answer.

---

1º - When we click to create a new item in CMS, it automatically got created in the end of the list. This is really really bad when u got a bunch of articles and need to scroll down a lot to find it. Is there any way to the new item be created in the FIRST of the list, and not last?

---

2º - I have been trying to use this command in some controllers:

static $default_sort = "Created DESC";

The main objective is just to sort a specific list i need.
But it just brings no effect, tried to use Created, Title and others default rows... but never works (SilverStripe 2.4.4).

So, i made the hard decision to force it in "_config.php" using:

SiteTree::$default_sort = "Created DESC";

OK, it works fine, but i got all the tree sorted.

How can i do a specific sort in a specific page i need?

---

I'm trying to avoid change SilverStripe core, always using its own parameters.
Sorry my bad english guys, i'll would be grateful for your help.

Avatar
Willr

Forum Moderator, 5513 Posts

18 January 2011 at 6:14pm

I have been trying to use this command in some controllers:

It shouldn't be in the controller, this is a model level variable. So try setting public $default_sort = "Created DESC"; on your subclassed model.

Avatar
Miroke

Community Member, 9 Posts

19 January 2011 at 2:43am

I made it, but $default_sort just don't work (and every topic says the same).
The main objective is sort the CMS Tree, but the only way possible right now is editing "_config.php".

Can you give a look?

Avatar
Miroke

Community Member, 9 Posts

15 February 2011 at 2:30am

Edited: 15/02/2011 2:36am

I just figured out there's no solution for truly sort the tree.

So i used pter's magic module called "hidepages" ( http://www.silverstripe.org/customising-the-cms/show/11471?start=32#post293932 ) that can make your own rules to sort the list.

I really think SilverStripe could use this options in "$defaults" but it can't yet.

Hope this can help other people.