17488 Posts in 4473 Topics by 1978 members
|Go to End|
20 April 2008 at 12:01am Last edited: 20 April 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.
MyClass extends DataObject
So my question is: what happens if i later decide to Change to Derive from Page
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?
23 April 2008 at 9:51am Last edited: 23 April 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...
|Go to Top|