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

What to do if I want to use the DataObjectManager with different types of pages?


Go to End


2 Posts   1050 Views

Avatar
WebSpilka

Community Member, 89 Posts

3 October 2009 at 4:00am

Now I add photos to the FotoPage with DataObjectManager (Class Foto):

class Foto extends DataObject
{
	static $db = array (
		'Name' => 'Text',
		'Description' => 'Text',
	);
	
	static $has_one = array (
		'Attachment' => 'File',
		'FotoPage' => 'FotoPage'
	);
	
	public function getCMSFields_forPopup()
	{
		return new FieldSet(
			new TextField('Name'),
			new TextareaField('Description'),
			//new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
			new FileIFrameField('Attachment')
		);
	}
}

what should I do to use the module on different types of pages: FotoPage and NewsPage?
may be sufficient to fix the code only:
'FotoPage' => 'FotoPage'
on
'FotoPage' => 'Page'
?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

3 October 2009 at 4:03am

You can add as many relations as you want.

static $has_one = array (
'Attachment' => 'File',
'FotoPage' => 'FotoPage',
'SomeOtherPage' => 'SomePage',
'AnotherPage' => 'AnotherPage'
);