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?
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:
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?
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.
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
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
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 useIContentService.GetById
and set the value of properties of the returned entity. There are quite a few pieces of deprecated documentation talking about using theDocument
entity to do this, butIContent
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
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
is working on a reply...