I am coming from Sitefinity where it is fairly easy to relate custom document types (called modules in Sitefinity) to each other. For instance, I have a custom Doc Type called Learning Track which has an ID and name. I also have a Course custom Doc Type which is related to one or more Learning Tracks. Is there any way to relate the two easily in the backend? Thanks!
Usually, a simple relationship like that can be done using a picker of some sort on the Course doctype — I think you should have a look at the nuPickers package, which contains a wide range of pickers for setups like that. If, say, you have a total of 5 Learning Tracks, then you could add a CheckBoxPicker to the Course doctype, so that you pick one ore more Learning Track nodes for that specific Course. The picker is "live", so if you add another Learning Track, it will appear on all Course nodes right away.
Most of the nuPickers also lets you store a "real" Relationship (in API terms) between the nodes that are picked and the one picking them, which you can use for various purposes, though it's not necessary.
Thanks for your help with the nuPickers. I see them mentioned in one of the article that Dennis sent as well. They work wonderfully. I am using SQL to fetch my list. As I am still a little unfamiliar with the database schema, do you see any problems with the following statement? Is there a better way to do this without using SQL?
SELECT cmsDocument.text AS Label, cmsDocument.nodeId AS [Key]
FROM cmsDocument INNER JOIN
cmsContent ON cmsDocument.nodeId = cmsContent.nodeId INNER JOIN
cmsContentType ON cmsContent.contentType = cmsContentType.nodeId
WHERE (cmsContentType.alias = 'Course') AND (cmsDocument.published = 1)
ORDER BY Label
Relating Document Types to each other
I am coming from Sitefinity where it is fairly easy to relate custom document types (called modules in Sitefinity) to each other. For instance, I have a custom Doc Type called Learning Track which has an ID and name. I also have a Course custom Doc Type which is related to one or more Learning Tracks. Is there any way to relate the two easily in the backend? Thanks!
Hi Solomon and welcome to our :-)
I think that you could set up and relation type, I must admit that I haven´t used myself, but I hope those links can help you further. The first link is from the Umbraco advent calendar 2012 http://24days.in/umbraco/2012/who-picked-this/ and there is also a API for the relation https://our.umbraco.org/documentation/reference/Management-v6/Services/RelationService
https://our.umbraco.org/documentation/Reference/Management/Relations/relationtype and a older blogpost from the Umbraco blog. http://umbraco.com/follow-us/blog-archive/2012/12/7/getting-to-know-umbraco-relations
You wil find the folder under developer section --> Relation Types
Hope this can help you further.
/Dennis
Thank you. Do you know of any resources for v7? Seems like a lot of this functionality got left behind in previous versions.
Hi Solomon,
Usually, a simple relationship like that can be done using a picker of some sort on the Course doctype — I think you should have a look at the nuPickers package, which contains a wide range of pickers for setups like that. If, say, you have a total of 5 Learning Tracks, then you could add a CheckBoxPicker to the Course doctype, so that you pick one ore more Learning Track nodes for that specific Course. The picker is "live", so if you add another Learning Track, it will appear on all Course nodes right away.
Most of the nuPickers also lets you store a "real" Relationship (in API terms) between the nodes that are picked and the one picking them, which you can use for various purposes, though it's not necessary.
/Chriztian
Thanks for your help with the nuPickers. I see them mentioned in one of the article that Dennis sent as well. They work wonderfully. I am using SQL to fetch my list. As I am still a little unfamiliar with the database schema, do you see any problems with the following statement? Is there a better way to do this without using SQL?
Hi Solomon,
Your SQL works fine :) although you could use the XML pickers instead and get all published Courses with the following XPath expression:
much simpler configuration, but the order of the Xml one will be the order of the courses in the content tree.
Much easier. Thanks.
Hi Solomon,
I have an example of creating relations with the use of nuPickers in this article :
http://skrift.io/articles/archive/the-king-is-dead-long-live-the-king/
Dave
is working on a reply...