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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Combining two DataObject


Go to End


10 Posts   5984 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, 99 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