I have a website where a number of nodes share some basic data. So when I update the data on a node, I would like to update/sync the other nodes with the data. So I guess it would be sufficient to store a many-to-many relationship based on the nodeIds. When I then update a node, I can fetch the other nodes based on their Ids and then update the data on each node.
But I don't know how to achieve this with the relationship API. As far as I can tell from the relationship API, it only supports relationship between two nodes, and I need relationships between X number of nodes.
if you use a Parent to Child RelationType and link A to B, and then A to C, it's possible to return B and C supplying the parameter A, ie. returning a collection of IDs linked to the ID of the node just updated, is this what you're after ?
I installed the RelationTypes package, but I cannot create any relation types (the create option is not there when I right click and the create-button is greyed out). Any suggestions?
You don't need to install the Relation Types package, (it works in 4.6.1) but it does offer a nice UI to be able to manage the rows in the umbracoRelationType table.
I've noticed that too, but only occasionly which is odd - if you restart the app, the right click actions should then appear... would be good to solve this one...
Creating a many to many relationship between nodes
Hi
I need to link a number of nodes and as far as I can tell, the relationship API does not support many to many relationships.
I am thinking about placing the relationships in a custom table, but I don't know, if there is a better way of doing it?
thanks
Thomas
Hi Thomas,
Can you give an example as to the data you'd like to associate ? The relationship API can be used to link many to many...
Cheers,
Hendy
Hi Hendy
I have a website where a number of nodes share some basic data. So when I update the data on a node, I would like to update/sync the other nodes with the data. So I guess it would be sufficient to store a many-to-many relationship based on the nodeIds. When I then update a node, I can fetch the other nodes based on their Ids and then update the data on each node.
But I don't know how to achieve this with the relationship API. As far as I can tell from the relationship API, it only supports relationship between two nodes, and I need relationships between X number of nodes.
thanks
Thomas
Hi Thomas,
if you use a Parent to Child RelationType and link A to B, and then A to C, it's possible to return B and C supplying the parameter A, ie. returning a collection of IDs linked to the ID of the node just updated, is this what you're after ?
Cheers,
Hendy
I would like to support the following scenarios:
When I update node A, I also update node B and node C
When I update node B, I also update node A and node C
When I update node C, I also update node A and node B
So what your are suggesting is to create Parent to Child RelationTypes for A->B and A->C.
Another set of Parent to Child RelationTypes for B->A and B->C.
And yet another set of Parent to Child RelationTypes C->A and C->B ?
Which I guess would be fine since my custom table would also create the following relationships:
A->B
A->C
B->A
B->C
C->A
C->B
Cheers,
Thomas
Hi Thomas,
How about using a single bidirectional RelationType and linking:
A <---> B
A <---> C
B <---> C
a query looking for B will return A and C
HTH,
Hendy
Hi Hendy
that seems to be the best solution. Thanks!
Do I need to install the Relation Types package first (btw I am on umb 4.6.1)?
thanks
Thomas
Hi Hendy
I installed the RelationTypes package, but I cannot create any relation types (the create option is not there when I right click and the create-button is greyed out). Any suggestions?
thanks
Thomas
Hi Thomas,
You don't need to install the Relation Types package, (it works in 4.6.1) but it does offer a nice UI to be able to manage the rows in the umbracoRelationType table.
Cheers,
Hendy
Hi Hendy
just recompiled and republished the site and now I can create the RelationTypes using the Relation Type package :-)
Cheers
Thomas
Hi Thomas,
I've noticed that too, but only occasionly which is odd - if you restart the app, the right click actions should then appear... would be good to solve this one...
Cheers,
Hendy
Hi Hendy
It works :-)
One last thing, is it possible to expose the relationships on a node in the backend?
thanks
Thomas
Hi Thomas, I started on that, the source in CodePlex has an additional tab that lists out the Relations for a particular Relation Type...
HTH,
Hendy
Hi Hendy
thank you very much for your help. It is much appreciated.
best regards
Thomas
is working on a reply...