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 /

Pages order in menu/cms


Go to End
Reply


12 Posts   5090 Views

Avatar
Jarek

Community Member, 30 Posts

10 February 2009 at 9:28am

Hello

When I'm creating subpage in CMS, page is added as last tree leaf (in menu also is last). I want to put newest pages at first positions, not last. So each time I'm adding page I have to move it to the first position (very irritating when there is menu subpages). Is there easy way to modify cms code to add pages default at first place?

Avatar
Brig

Community Member, 26 Posts

31 July 2009 at 1:07am

I'm interested in doing this as well. Especially for a news section. The latest article should appear at the top.

Anyone knows how this can be done please?

Avatar
cbartgu

Community Member, 12 Posts

31 July 2009 at 10:36pm

Anyone have any ideas on how to do this?

Avatar
Willr

Forum Moderator, 5513 Posts

31 July 2009 at 11:13pm

Can't say if this will work for new pages but you can specify a default_sort on Page.php which will display the pages sorted in a given order

Add this to your page.php, reload the admin with a ?flush=1 and see what happens

static $default_sort = "Created DESC";

Tho I think adding will append it always to the bottom, but try that and see what happens

Avatar
cbartgu

Community Member, 12 Posts

1 August 2009 at 1:41am

Edited: 01/08/2009 1:44am

Thanks for the reply, I want to display the pages by the date order they are in (my date field), not the creation date, though, also where abouts do you put the code,

if you could help with that, that would be great,

Thanks,

Avatar
Carbon Crayon

Community Member, 598 Posts

1 August 2009 at 1:56am

Edited: 01/08/2009 1:56am

@ cbartgu - Put that in your PageType class, so if you wanted to add it to ArticlePage you would ahve the following:

class ArticlePage extends Page{

static $db = array(
'Date' => 'Date'
);

static $default_sort = "Date DESC";

function getCMSFields(){

etc.....

}

}

Avatar
cbartgu

Community Member, 12 Posts

3 August 2009 at 10:40pm

Thanks again, I tried it but it does not change the child pages are still ordered by the id I think, this is what I have got,

class BreakPage extends Page {
static $db = array(
'Date' => 'Date',
'Category' => "Enum('cat1,cat2,cat3')",
'Price' => 'Text',
'KidsPrice' => 'Text',
'Hilight' => 'Boolean',
    'Duration' => "MultiEnum('1 night only,2 nights,3 nights,4 nights,5 nights,Week Long')",
    'Type' => "MultiEnum('Theme,Family,Adult')"
);

// an Article can have many Category objects associated with it.
// calling $this->getManyManyComponents('Categories') retrieves the associated Category objects.

// this classes default parent is an ArticleHolder page type
static $default_parent = 'ActivityHolder';

static $default_sort = "Date DESC";

function getCMSFields() {
$fields = parent::getCMSFields();

etc

Avatar
Thomashv

Community Member, 33 Posts

22 June 2010 at 8:56pm

I also have a problem width this:
static $default_sort = "Created DESC";
or
static $default_sort = "Created ASC";
doesn't change anything. Running SilverStripe 2.4.

Does anyone have a clue why this happens? Could it be a default sort overriding the sort added to the class somewhere?

Go to Top