Can someone explain what a good generic strategy is for doing one to many relationships. A good example would be something like a portfolio page where you have:
Something like this
Portfolios
-Category 1
-- Example A (name, description, photo(s))
-- Example B (name, description, photo(s))
-Category 2
-- Example C
-- Example D
-- Example A
-Category 3
-- Example C
-- Example B
These are all roughly document types but I just can't seem to figure out how to do a relationship like this?
FYI, you can automatically create relations from the multipicker selected values using the MultiPicker Relations datatype in uComponents - this can be especially useful for reverse lookups, eg, find all Examples in Category 1.
You should post link not to package but to your blog article Umbraco MultiPicker Relations because it much more extended.
Please correct me if i did't catch technics of your proposal
1. we should add Relation Types package and uComponents package for Multipicker relations to the website
2. we should create relationships for Category to Example and Example to Category using Relations Types package
3. Create custom DataType from Multi Node Tree Picker control (for example, complete list of controls in Hendy's blok follow previous link) and set up Xpath in its properties to select only \\Category datatype.
4. We should create new datatype from MultiPicker relations control and configure it to use Example to Category, and create second datatype to use Category to Example relation.
2) if you just want to know that a Category is related to an Example (or via-se-versa) but the direction isn't important then you could use a single Bidirectional Relation Type instead.
Here's the Xslt example (it went missing from the blog post somehow)
<xsl:variablename="colourNodeId"select="123"/> <xsl:variablename="relations"select="umbraco.library:GetRelatedNodesAsXml($colourNodeId)//relation[@typeName='Colours to Product']"/>
Been a good discussion. My only beef with the UI is that there is no good way to show an administrator on the tree how items are related (that I know of). It would be great if there was a "tree view" that showed this so that you could actually see at a glance where the items are without having to open different documents. Anyways, I'm using the Multinode Picker for now since the project I'm on isn't too difficult.
That's one of the really nice things about wiring up MultiPickers to RelationTypes (especially a reverse Parent to Child RelationType) as it's easy to use the Relations as a data source for a custom tree. (humm.. how about being able to automatically configure such trees somehow, and which section would they go in ?)
The RelationTypes package (the version on CodePlex) allows you to see relations for a given RelationType.
Generic Strategy for 1 to many relationships
Can someone explain what a good generic strategy is for doing one to many relationships. A good example would be something like a portfolio page where you have:
Something like this
Portfolios
-Category 1
-- Example A (name, description, photo(s))
-- Example B (name, description, photo(s))
-Category 2
-- Example C
-- Example D
-- Example A
-Category 3
-- Example C
-- Example B
These are all roughly document types but I just can't seem to figure out how to do a relationship like this?
Thanks in advance.
I tried to change the title but it won't save - I meant to put Many to Many relationships.
I did it in this way, You create documents separately. So You will have
Categories
-Category 1
-Category 2
-Category 3
Portofolio
-Example a
-Example b
-Example c
Create Data type of Ultimate Picker which ParentID is fixed to ID of Category? and add this data type to Examples.
When you would like to put all examples in one place by category you will do it in xslt like this
But if your web getting large youll have to seek for Relationships API
Umbraco Relation API ยป Hendy's Blog
Hi Kouzzmitch,
FYI, you can automatically create relations from the multipicker selected values using the MultiPicker Relations datatype in uComponents - this can be especially useful for reverse lookups, eg, find all Examples in Category 1.
Cheers,
Hendy
Thanks Hendy
You should post link not to package but to your blog article Umbraco MultiPicker Relations because it much more extended.
Please correct me if i did't catch technics of your proposal
1. we should add Relation Types package and uComponents package for Multipicker relations to the website
2. we should create relationships for Category to Example and Example to Category using Relations Types package
3. Create custom DataType from Multi Node Tree Picker control (for example, complete list of controls in Hendy's blok follow previous link) and set up Xpath in its properties to select only \\Category datatype.
4. We should create new datatype from MultiPicker relations control and configure it to use Example to Category, and create second datatype to use Category to Example relation.
5. AddDatattypes from 3,4 to Example doctype
You wrote how to retrieve related items from c#
but i have not found just how to use it from xslt
Thanks Kouzzmitch,
I think you've got it spot on :)
Just to clarify:
2) if you just want to know that a Category is related to an Example (or via-se-versa) but the direction isn't important then you could use a single Bidirectional Relation Type instead.
Here's the Xslt example (it went missing from the blog post somehow)
(btw, there are some extension methods in uQuery for working with the RelationType object)
HTH,
Hendy
Been a good discussion. My only beef with the UI is that there is no good way to show an administrator on the tree how items are related (that I know of). It would be great if there was a "tree view" that showed this so that you could actually see at a glance where the items are without having to open different documents. Anyways, I'm using the Multinode Picker for now since the project I'm on isn't too difficult.
Hi Lucuma,
That's one of the really nice things about wiring up MultiPickers to RelationTypes (especially a reverse Parent to Child RelationType) as it's easy to use the Relations as a data source for a custom tree. (humm.. how about being able to automatically configure such trees somehow, and which section would they go in ?)
The RelationTypes package (the version on CodePlex) allows you to see relations for a given RelationType.
HTH,
Hendy
is working on a reply...