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.

Data Model Questions /

Combining two DataObject


Go to End
Reply


10 Posts   4484 Views

Avatar
pbenoit

Community Member, 9 Posts

31 August 2012 at 2:25am

Just want to say thanks! This thread helped me through merging two child pages into one 'holder page', appreciate the info.

Avatar
merrick_sd

Community Member, 97 Posts

9 April 2013 at 3:53am

Edited: 10/04/2013 9:45pm

Can anyone help. I would like to limit my results.

$numlimit = 10;
$numlimit = $this->LatestDocCount;

$ds = new DataObjectSet();

$ds->merge(DataObject::get("SiteTree", "ClassName = 'Download' AND Created > DATE_SUB(NOW(),INTERVAL 14 DAY) OR ClassName = 'Download' AND LastEdited > DATE_SUB(NOW(),INTERVAL 14 DAY)", "Created DESC, LastEdited DESC", ""));

$ds->merge(DataObject::get("DocumentResource", "Created > DATE_SUB(NOW(),INTERVAL 14 DAY) OR LastEdited > DATE_SUB(NOW(),INTERVAL 14 DAY)", "PageID, Created DESC, LastEdited DESC", ""));

$ds->sort('LastEdited', 'DESC' );

return $ds

SOLUTION this worked for me

public function LatestDocuments() {

$numlimit = 10;
$numlimit = $this->LatestDocCount;

$ds = new DataObjectSet();

$ds->merge(DataObject::get("SiteTree", "ClassName = 'Download' AND Created > DATE_SUB(NOW(),INTERVAL 14 DAY) OR ClassName = 'Download' AND LastEdited > DATE_SUB(NOW(),INTERVAL 14 DAY)", "Created DESC, LastEdited DESC", ""));

$ds->merge(DataObject::get("DocumentResource", "Created > DATE_SUB(NOW(),INTERVAL 14 DAY) OR LastEdited > DATE_SUB(NOW(),INTERVAL 14 DAY)", "PageID, Created DESC, LastEdited DESC", ""));

$ds->sort('LastEdited', 'DESC' );

//getRange
$records = $ds->getRange(0, $relimit);
return $records
}

Go to Top