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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

Combining two DataObject


Go to End


10 Posts   7092 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