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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Order DataObjectManager by Date


Reply

5 Posts   753 Views

Avatar
DeklinKelly

18 August 2010 at 4:38am Community Member, 197 Posts

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);

Avatar
UncleCheese

18 August 2010 at 6:22am 4085 Posts

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

Avatar
DeklinKelly

18 August 2010 at 7:27am Community Member, 197 Posts

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'
);

Avatar
UncleCheese

18 August 2010 at 9:41am 4085 Posts

Looks okay to me. Where's the error?

Avatar
DeklinKelly

18 August 2010 at 10:27am Community Member, 197 Posts

I found the problem. I had to replace

null

with

''