silverstripedata-objects

When to use Page vs Dataobject in Silverstripe


When to use Page vs Dataobject as ancestor in Silverstripe when creating data tables. I guess inheriting from Page class gives the data table page functionality but what are those page functionalities?


Solution

  • You guess right ;) It's often a matter of taste what to use, both are fine for most scenarios.

    Default Page functionalities are e.g. Versioning (stage / live), urlsegment and nesting of pages, you can define $allowed_children (what page types can be children of that page), who can view and edit the page... There might be some overhead for some reasons.

    If you don't use it as standalone object with a given nested url you might think about using a plain DataObject for it.

    With Modules like lumberjack or catalogmanager on the other hand you can edit some page types in a GridField or ModelAdmin like plain dataobjects.

    So both ways have their pros and cons and it's up to you what you find better. Just try it out and play with it.