Jump to:

7939 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Order DataObjectManager by Date

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 740 Views
  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Order DataObjectManager by Date Link to this post

    How can I sort DataObjectManager items displayed in the administrative area by date?

    Here is my code:

    class FeaturedAuthorScheduleItem extends DataObject
    {
       static $db = array (
          'Date' => 'Date',
          'Author' => 'Text'
       );

       public function getCMSFields_forPopup()
       {

       $AllMember = DataObject::get('Member');
       $Emails = array();
       foreach($AllMember as $Member) {
        $Emails[trim($Member->Email)] = trim($Member->Email);
       }
          return new FieldSet(
             new CalendarDateField('Date','Date (Day/Month/Year)'),
             new ListboxField('Author',"Author's Email Address",$Emails,0)
          );
       }
    }

    ?>

    and

    $obj = new SiteConfig_DataObjectManager (
    $this->owner,
    'FeaturedAuthorScheduleItem',
    'FeaturedAuthorScheduleItem',
    array('Date'=>'Date','Author'=>'Author'),
    'getCMSFields_forPopup'
    );
    $obj->setSourceID($this->owner->ID);
    $obj->setAddTitle("Featured Author Schedule");
    $obj->set_popup_width(630);
    $fields->addFieldToTab("Root.Content.TopRow.FirstColumn", $obj);

  • UncleCheese
    Avatar
    4085 Posts

    Re: Order DataObjectManager by Date Link to this post

    The sort clause is the 7th argument of the DOM constructor. (8th for a FileDOM).

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: Order DataObjectManager by Date Link to this post

    Thanks, any idea why this would give me a parse error? Am I putting the argument in the wrong place?

    $obj = new SiteConfig_DataObjectManager (
    $this->owner,
    'FeaturedAuthorScheduleItem',
    'FeaturedAuthorScheduleItem',
    array('Date'=>'Date','Author'=>'Author'),
    'getCMSFields_forPopup',
    , null
    ,'Date ASC'
    );

  • UncleCheese
    Avatar
    4085 Posts

    Re: Order DataObjectManager by Date Link to this post

    Looks okay to me. Where's the error?

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: Order DataObjectManager by Date Link to this post

    I found the problem. I had to replace

    null

    with

    ''

    740 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.