Jump to:

23358 Posts in 17875 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Best Way To Create This Structure

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 676 Views
  • DanStephenson
    Avatar
    Community Member
    115 Posts

    Best Way To Create This Structure Link to this post

    Hi everyone,

    I have a new website I am hoping to build on SilverStripe. I have a bit of a problem though, in that I have a bit of a weird structure I need, and am trying to find a "client friendly" solution so they can manage this themself.

    The client has a variety of products who they want to display on their website, but they want to be able to display these items in many different categories. Each product can be in one or more category at the same time.

    Normally, I'd create my categories as pages, and just add products in as sub pages for the category they're in, if there is a 1-to-1 relationship.

    However, now I am trying to find an easy way to allow the client to create a product, and then select multiple categories. My original idea was to just create the same structure I used above, but use a RedirectorPage to "place the product" into different categories. However, that's not ideal for clients.

    Does anyone have another idea of how I could achieve this in a client friendly way?

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: Best Way To Create This Structure Link to this post

    What you want is a many_many structure. Depends on how you want to do it but you could have a page for each category then a checkboxsetfield to select the categories a page exists in OR use a treemultiselect field would be another way of having a many_many releation.

    See this tutorial for a bit of background to the relationships http://doc.silverstripe.org/tutorial:5-dataobject-relationship-management

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Best Way To Create This Structure Link to this post

    I'd also like to suggest that this *maybe* best outside of the sitetree... the pages could be dynamically created from dataobjects and you could use modeladmin to manage the categories and products - this also means you could easily control user access to the category/product data without exposing the rest of the sitetree for them to change. also I'd suggest using multiselectfield to manage the many to many relationship.

    676 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.