3060 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1253 Views |
-
How to merge two DataObjectSets

16 April 2010 at 9:25am Last edited: 16 April 2010 9:26am
Hey guys,
Really simple one here. I'm wondering if one can take two DataObjectSets (from two separate DataObject::get requests) and join them together.
I have two different DataObjects, Module.php and Course.php. I want to call both of them using one function, so I can order both Modules AND Courses by Title ASC using a control block.
Currently the code I have is:
function Modules(){
return DataObject::get("Module");
}function Courses(){
return DataObject::get("Course");
}Can I do what i'm trying to achieve in it's own function? Or can I reference the above functions in another function to achieve the join?
Cheers,
Josh -
Re: How to merge two DataObjectSets

17 August 2010 at 9:01am
how about...
function Composite()
{
$dosComposite = new DataObjectSet();
$dosComposite->merge($this->Modules());
$dosComposite->merge($this->Courses());
$dosComposite->sort('FieldName','ASC');
return $dosComposite;
}
| 1253 Views | ||
|
Page:
1
|
Go to Top |



