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


Reply

10 Posts   4295 Views

Avatar
pbenoit

31 August 2012 at 2:25am Community Member, 9 Posts

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

Avatar
merrick_sd

9 April 2013 at 3:53am (Last edited: 10 April 2013 9:45pm), Community Member, 95 Posts

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
}