Jump to:

3462 Posts in 1065 Topics by 740 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Relating a page to itself

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

Page: 1
Go to End
Author Topic: 1010 Views
  • MarcusDalgren
    Community Member
    288 Posts

    Relating a page to itself Link to this post


    Today I tried relating a page to itself and it kind of works. I have a situation where I'm creating a product catalog and the products can be related to eachother.

    I set this up by letting the ProductPage both have a $many_many and a $belongs_many_many to itself. I ran this through the build and so far so good.

    For editing I set up a ManyManyComplexTableField (see the attached file).

    Now to my issues.
    The first issue is that I want to get rid of the add product-button. I don't want the user to be able to add a page through this, just manage relationships between existing pages.

    The second issue is that the relationship is not two sided in the way I had hoped. If I check the checkbox for Product 1 to be related to Product 2 and 3 then I want Product 1 to be checked on Product 2 and 3. This is not working right now.

    Is there any way for me to write a custom getter method or something to show the relationships in a two sided fashion and is there any way to get rid of the add button?

    Kindly, Marcus.

    Attached Files
  • Willr
    Forum Moderator
    5511 Posts

    Re: Relating a page to itself Link to this post

    Number 1 is straight forward but #2 is a bit weird. #1 Just remove add an option in the permissions. For example below the user can only export or print (not delete or add)


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.