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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Joining two tables created using DataObject


13 Posts   3202 Views

Carbon Crayon

3 May 2011 at 11:26pm Community Member, 598 Posts

Hi Guy,

Not entirely sure what you mean but take a look at this, it's the same principle:

Aram - Your one stop SilverStripe learning resource.


4 November 2011 at 9:48am Community Member, 8 Posts

@guywatson - did u manage to find a solution to this?

I'm having the same issue. I saw that the constructed query only select fields from the first table in the DataObjectManager even if you JOIN another table. If I can find a way to add the required field to the select query, it would solve my problem (I hope). It also ads a GROUP BY clause, which would make it challenging to add another field in the query.

Any help guys? I started a topic on this exact issue which I assume is related here (


4 November 2011 at 10:08am (Last edited: 4 November 2011 10:29am), Community Member, 16 Posts

Hi ROlckers

This seems to be a problem with dom, because it works fine with complex table fields. I still needed to use a dom however so the way i got around it was to create a get function on the CustomModel dataobject i.e. something like this

public function getCustomParentPageTitle() {
   return $this->CustomParentPage()->Title;

Then in the XYZ Page

public function getCMSFields() {
   $fields = parent::getCMSFields();
   $fields->addFieldToTab("Root.Content.CustomWidgets", new DataObjectManager(
      array( 'CustomName' =>'Custom Model Name',
         'CustomParentPageID' =>'Custom Parent Page ID'
         'CustomParentPageTitle' =>'Custom Parent Title' ),
      '   getCMSFields_forPopup'
   return $fields;

Note you omit the get and CustomParentPageTitle is the function call on the dataobject

Also you should just be able to go CustomParentPageID.Title, but this doesn't work for me (well on a many_many relationship) i haven't tried a has_many relationship



4 November 2011 at 10:30am Community Member, 8 Posts

Great, I'll play around with that. Thanks.


4 November 2011 at 11:14am Community Member, 8 Posts

Legend! I took the $has_one column id, and used that inside the function, there I could use any calculation to get the Title from SiteTree or from another model.