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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Can DataObjects have Controllers?


Go to End


2 Posts   1697 Views

Avatar
Jonn

Community Member, 10 Posts

13 January 2011 at 4:31pm

Edited: 13/01/2011 4:32pm

Hi,

Can DataObjects have controllers like:

class SomeObject extends DataObject {
...
}

class SomeObject_Controller extends ContentController {
...
}

and would that controller work the same way the page controllers work?

I've tried a few different ways of doing this but the methods inside the controller aren't recognized on the page.

Thanks.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

13 January 2011 at 6:14pm

No, a DataObject is just arbitrary data. It doesn't know anything about templates or controllers. You'll have to build a custom page controller to display the content of a DataObject.

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com