Copied to clipboard

Flag this post as spam?

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


  • Rob Gibson 13 posts 94 karma points
    Nov 18, 2014 @ 20:22
    Rob Gibson
    0

    Display/Order Reciprocal Page Relationships

    Hello, I've been trying to support a use case with Umbraco that requires a many:many relationship between articles and hub pages that contain them. Part of our requirements has been that users be able to specify which hub page an article is to be located on during article creation, but that the articles contained on hub pages could be later re-ordered or pruned from a hub page configuration.

    Normally, I would have simply used the standard tree structure to model the articles to their hubs, however our requirements also state that an article be able to exist on multiple hubs simultaneously. I'm at my wits end as to how I can properly allow the association to be created at article creation time and to also display the members of the hub relationship on the hub page. It's like the hub really should own the articles, but then how should I handle article creation?

    At a loss and hoping for any tips,

    Rob

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Nov 18, 2014 @ 23:53
    Jeavon Leopold
    1

    Hi Rob,

    An approach here is to use Umbracos native relation support probably by attaching an event on Content Save and then creating the relation using the RelationService.

    There are quite a few good blog posts on using Umbraco relations:

    And also worth noting that nuPickers has a lot of support for Relations picking and viewing. In v7.

    Hope that's helpful?

    Jeavon

  • Rob Gibson 13 posts 94 karma points
    Nov 18, 2014 @ 23:58
    Rob Gibson
    0

    Thanks Jeavon, this is exactly the approach I was looking for. I spent awhile spinning my wheels against being unable to update the value of a property of a Node, but then I realized I could use IContentService.GetById and set the value of properties of the returned entity. There are quite a few pieces of deprecated documentation talking about using the Document entity to do this, but IContent is the current interface.

    I haven't dug into it too deeply, but what benefit is there to using relations in Umbraco? Are there built-in functions that I would get to use, or would I be just as well served rolling my own reciprocal relationship?

    Rob

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Nov 19, 2014 @ 00:17
    Jeavon Leopold
    0

    No problem, you would get access to all the methods from the RelationService as documented here and as it already exists in Umbraco it is a good way for two way lookups.

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft