Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Adding "where" clause to new DataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 394 Views
  • Fraser
    Avatar
    Community Member
    46 Posts

    Adding "where" clause to new DataObjectManager Link to this post

    I need to add a where clause to my DataObjectManager.

    My existing code looks like this:

    $fields->addFieldToTab('Root.Backgrounds', new ImageDataObjectManager(
             $this->owner,
             'BackgroundImages',
             'BackgroundImage',
    ));

    I have tried simply adding it like the below but it doesn't apply the filter and I always end up with all the BackgroundImages returned, not those with the required SubSiteID.

    $fields->addFieldToTab('Root.Backgrounds', new ImageDataObjectManager(
             $this->owner,
             'BackgroundImages',
             'BackgroundImage',
             "'BackgroundImage.SiteConfigID' = '".$this->owner->SubsiteID."'"
          ));

    Can someone tell me where I am going wrong please?

    394 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.