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

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


Go to End
Reply


2 Posts   883 Views

Avatar
WebSpilka

Community Member, 85 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, 4096 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'
);