Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » custom sort order for SiteTree in CMS

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 3128 Views
  • Anatol
    Avatar
    126 Posts

    custom sort order for SiteTree in CMS Link to this post

    Hi,

    I'm looking for a way to apply a different sort order of the pages in the site tree in the CMS (the site tree on the left under the create, search and batch action buttons). By default this is ordered by the "Sort" column which makes perfect sense. For my project it would be better though to sort pages by a (new custom) field "Date" (in the `Page` database table).

    I have been looking through the source code for quite a while now but couldn't find the right piece of code. Does anyone know where I could find this or how to change it?

    Cheers!
    Anatol

  • MateuszU
    Avatar
    Community Member
    89 Posts

    Re: custom sort order for SiteTree in CMS Link to this post

    What about SiteTree::$default_sort ?

  • Anatol
    Avatar
    126 Posts

    Re: custom sort order for SiteTree in CMS Link to this post

    Hi Mateuzs,

    thank you for that! This works well (e.g. in /mysite/_config.php)

    SiteTree::$default_sort = 'LastEdited';

    The only problem left is that it only works for database fields of the SiteTree table. I extended the Page type with

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


    I would like to sort by 'Date' (which is in the database table 'Page', and I guess that's the problem).

    Any hint is much appreciated.

    Cheers!
    Anatol

  • dacar
    Avatar
    Community Member
    168 Posts

    Re: custom sort order for SiteTree in CMS Link to this post

    Hi, same problem here. It is no problem to change the order in the frontend templates. But how to change it in the cms sitetree if you want to order by a field written into an other table (eg. page)?

    Can anybody help?

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: custom sort order for SiteTree in CMS Link to this post

    A late reply perhaps but yes!

    There is a tutorial about it here.

  • Lisa Diane
    Avatar
    Community Member
    1 Post

    Re: custom sort order for SiteTree in CMS Link to this post

    Thanks you for sharing

    __________________
    Watch Unknown Online Free

    3128 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.