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.

Archive /

Our old forums are still available as a read-only archive.

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

later change of a parent


Go to End


2 Posts   1152 Views

Avatar
zyko

Community Member, 66 Posts

20 April 2008 at 12:01am

Edited: 20/04/2008 12:03am

Hi Dear Silverstripe,

I'm dealing around with some thinking about
how to best implement my classes in Silverstripe.
There i'm missing some understanding in how saphire does changes on class-inheritance.

As far as i can see, it seems to be a good Idea to derive from Page
if i want to have things shown on a own html page
and to derive from DataObject if i only want to persist things
and show them fe. only within list of other things.

But I've got a few classes, where i'm definitely not sure, whether it's best to derive from Page or from DataObject.

I thought to first start with a 'DataObject' derivation.
fe:
MyClass extends DataObject
...

So my question is: what happens if i later decide to Change to Derive from Page
fe:
MyClass extends Page
..

Are all till now created Instances lost for 'MyClass'?
Will the be reused, and 'extended' by the additional data?

But if, they're missing the 'parent' Page, so how could i find them?

And same way back around. Can i change from a Page Class back to DataObject derived, so that all additional columns are thrown away?

Avatar
zyko

Community Member, 66 Posts

23 April 2008 at 9:51am

Edited: 23/04/2008 9:52am

as far as i can see, data will be lost.
Any DataObject derived Class has it's own table
where id's are created with 'new max value' within this table.

So later redefining it to a Page Derived thing would'nt work without
id transfering to fit the next 'maxval' for SiteTree.

So i would recommend to think carefully about this things.
to derive from Page makes many things a lot easyer...
g
Helmut