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:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Adding "where" clause to new DataObjectManager


Go to End


804 Views

Avatar
Fraser

Community Member, 48 Posts

6 July 2012 at 4:32pm

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?