I would like to get some input on how I plan to setup the classes and relationships for a particular site . I'll start with an description of the site and follow that with the explanation of how I plan to implement it in Silverstripe. My apologies if it runs a little long.
Most of the site will be simple pages with text and no advanced functionality. The exception is the 'Products' section which is outlined in the site tree below.
Product Line 1 : info page, just text and an image.
----Customer Type : group label to organize sub-menus, not a link or page
--------Type 1 : ProductHolder - lists products defined in a many-many relationship, product detail page provided by class method
--------Type 2 : ProductHolder
--------Type 3 : ProductHolder
----Product Category : group label
--------Category 1 : ProductHolder
--------Category 2 : ProductHolder
--------more categories
Product Line 2 : info page
----Product Category : group label
--------Category 1 : ProductHolder
--------Category 2 : ProductHolder
--------more categories
Product Line 3 : info page
----Related Service : info page
----Product Category : group label
--------Category 1 : ProductHolder
--------Category 2 : ProductHolder
--------more categories
What makes this tricky (to me at least) is that the product catalog for each product line is separate from the others but the behavior needed in each product line is otherwise identical as are the requirements for the product dataobjects.
What I take this to means is that I need to define different ProductHolder page types and dataobjects for each product line to manage the relationships properly. But I also don't want to be repeating myself and make maintenance more difficult than it needs to be.
So here are the classes I plan to create to make this work.
- *Overview extends Page : adds an image to $db and the CMSFields, has it's own layout.
- *Label extends Page : removes Content from CMSFields, sub-menu include has if control to test ClassName and print title without link.
- *ProductHolder extends Page : abstract class, defines common logic, $db/CMSFields, etc in one place. Not to be used to actually create pages in the cms.
- *ProductObject extends DataObject : abstract class, defines the dataobjects fields, sets up method to assign template used to display objects, setsup getCMSFields_forPopup.
- *Line1Holder extends ProductHolder : at this point it only sets up the many_many relationship with the appropriate child of ProductObject. Same goes for Line2Holder, Line3Holder, etc.
- *Line1Object extends ProductObject : same as Line1Holder this should only need to setup the relatioship.
If this is a good setup then I'm particularly interested in whether ProductHolder and ProductObject can be explicitly defined as abstract or not and how to prevent database tables from being created from them since they won't be used.
Any advice or feedback is appreciated.