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:

Archive /

Our old forums are still available as a read-only archive.

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

Combining 2 DataObjectSet


Go to End


3 Posts   1878 Views

Avatar
freeyland

Community Member, 22 Posts

21 August 2007 at 10:28pm

Edited: 21/08/2007 10:58pm

Hi is there a way to combine 2 DataObjects into 1?

Avatar
Andante

Community Member, 231 Posts

23 August 2007 at 9:49am

I'm assuming you mean DataObjectSet as your topic says, not DataObject as your post says.

DataObjectSet has a function called merge that does this, so you can just go:

$doSet1->merge($doSet2);

Avatar
freeyland

Community Member, 22 Posts

23 August 2007 at 8:20pm

Thx for the reply!

It is combining the 2 ObjectSets, but as seperate arrays.
In the template it will loop and find 2 Objects (with Control). I want only to display once the content.

* ArrayData::__set_state(array( 'array' => array ( 'text' => 'Partly Cloudy', 'code' => '30', 'temp' => '19', 'date' => 'Thu, 09 Aug 2007 1:55 pm CEST', ), 'iteratorPos' => 0, 'iteratorTotalItems' => 2, 'failover' => NULL, '_object_cache' => array ( ), '_xml_cache' => array ( ), '_natural_cache' => array ( ), 'customisedObj' => NULL, 'show' => NULL, 'parent' => NULL, 'namedAs' => NULL, 'class' => 'ArrayData', ))
* ArrayData::__set_state(array( 'array' => array ( 'city' => 'Hermagor', 'region' => '', 'country' => 'AU', ), 'iteratorPos' => 1, 'iteratorTotalItems' => 2, 'failover' => NULL, '_object_cache' => array ( ), '_xml_cache' => array ( ), '_natural_cache' => array ( ), 'customisedObj' => NULL, 'show' => NULL, 'parent' => NULL, 'namedAs' => NULL, 'class' => 'ArrayData', ))