Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Neil Chapman 42 posts 170 karma points
    Sep 09, 2019 @ 16:24
    Neil Chapman
    0

    Managing many-to-many relationships (RelationService/RelationType) within the backoffice

    Hi,

    I have a list of Articles that can be related to multiple Categories, e.g. a many-to-many relationship. When viewing an Article in the backoffice, I would like to display all Categories (something like a checkbox list) so that content editors can check/uncheck which Categories the Article relates to.

    This would need to work the other way (bidirectional) when viewing a Category in the backoffice - list all Articles that are assigned to it and allow them to be managed.

    My first thought was to use the RelationType and RelationService...

    https://our.umbraco.com/Documentation/Reference/Management/Models/RelationType

    https://our.umbraco.com/Documentation/Reference/Management/Services/RelationService/Index/

    ...but there seems to be very little documentation/use cases for this context, especially for v8. I can understand how to override the save event to update the relations but not sure how this would work in the UI:

    https://our.umbraco.com/apidocs/v8/ui/#/api/umbraco.resources.relationResource

    The UI relation service documentation seems to be very limited.

    If I'm overwriting the save event it seems like I'm bypassing the RelationService so is it even required/the best route? I'm now wondering whether using a Content Picker on the Article and Category would be better to store the relation?

    If anyone has done anything similar or has any advice to point me in the right direction that would be very helpful.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft