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

Order DataObjectManager by Date


Go to End
Reply


5 Posts   846 Views

Avatar
DeklinKelly

Community Member, 197 Posts

18 August 2010 at 4:38am

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

Forum Moderator, 4096 Posts

18 August 2010 at 6:22am

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

Avatar
DeklinKelly

Community Member, 197 Posts

18 August 2010 at 7:27am

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

Forum Moderator, 4096 Posts

18 August 2010 at 9:41am

Looks okay to me. Where's the error?

Avatar
DeklinKelly

Community Member, 197 Posts

18 August 2010 at 10:27am

I found the problem. I had to replace

null
with
''