Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » later change of a parent

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

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

Page: 1
Go to End
Author Topic: 846 Views
  • zyko
    Avatar
    Community Member
    66 Posts

    later change of a parent Link to this post

    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?

  • zyko
    Avatar
    Community Member
    66 Posts

    Re: later change of a parent Link to this post

    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

    846 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.