I'm quite new to Umbraco and currently, I am using the Umbraco 7.2.
I decided to use Umbraco for a new website, and for the first time.
Now I got stucked when coming to relations between nodes, from the Umbraco back office.
Basically, I have two document types: Class and Student Then I want to relate a particular student with a class.
For exmaple, if I create a Class named 2HND, then I want to relate existing created students {Mark and Simon} with that class, maybe using relation types. But then I want that if I navigate to Mark or Simon Content page, I need to see the related school class, which is in this case is 2HND.
I have already tried it with MultipleNode Tree Picker but it is not such practical.
I have create Class named 2HND.
I have create Student named Mark.
Then I go back to class 2HND and related that class with student Mark. But If I go to Mark content page, I do not see the school class 2HND related, but I had to relate again Mark with 2HND,. which is not that such pratcial.
I would like something which actually create a relationship as described in my first email.
Do you have an idea how to use the nuPicker for my solution, linking class to students pls? Because i have installed but there is quite some fields, such as Assembly for DotNet, etc, which I don't have an idea how to implement it.
The first thing you need to do is create a relation type. You can do this under the developer section. Maybe you can read some more about relations in this post :
After you create your relation type you go to the developer section and create a new datatype called student picker. As a editor you choose nuPickers : Lucene PrefetchList. As Examine Searcher you choose InternalSearcher. In the Raw Query field you enter this : nodeTypeAlias:AliasOfYourStudentDoctype.
The other settings you are clear I think. On the bottom you have the option to choose a relation mapping. If you choose a relation there nuPickers will create the relation for you.
I tried to do a relationship, based on the guidlines that you have provided me, but when I created a content for Class, nothing showed next to Students.
I am attaching some screenshots to understand me better.
Also I see that you have student as a label field. Is student a property on your doctype ? If not just enter nodeName there. And also change ID to id to be sure.
Regarding the nuPickers Lucene, such as TypeaheadList, using the Raw Query, are there any guide of what type of quries that you can pass to this Raw Query for Lucene?
Since I want to not to get, for example all students, because if I have hundreds of students, and eventually choose only 1 or 2, are there any way how you can modify the query execute a database call based on the search for example?
Relationship between nodes from CMS - Umbraco 7+
Hi,
I'm quite new to Umbraco and currently, I am using the Umbraco 7.2.
I decided to use Umbraco for a new website, and for the first time.
Now I got stucked when coming to relations between nodes, from the Umbraco back office.
Basically, I have two document types: Class and Student
Then I want to relate a particular student with a class.
For exmaple, if I create a Class named 2HND, then I want to relate existing created students {Mark and Simon} with that class, maybe using relation types. But then I want that if I navigate to Mark or Simon Content page, I need to see the related school class, which is in this case is 2HND.
Appreciate any help.
Thank you very much.
Regards
Hi
You can solve this in 2 ways using Multinode picker or a picker from nuPickers package.
Solution 1:
On the class documenttype you add a picker that allows you to pick students
Solution 2 :
On the student documenttype you add a picker that allows you to pick a class.
Is this clear ?
Dave
Hi Dave,
Thank for your fast reply.
I have already tried it with MultipleNode Tree Picker but it is not such practical.
I have create Class named 2HND.
I have create Student named Mark.
Then I go back to class 2HND and related that class with student Mark. But If I go to Mark content page, I do not see the school class 2HND related, but I had to relate again Mark with 2HND,. which is not that such pratcial.
I would like something which actually create a relationship as described in my first email.
Any ideas?
Thanks Dave.
Regards
Hi,
You can hook in to the save/publish event and create a relation with the API. But I think nuPickers has support for creating relations out of the box.
See documentation for hooking in to content events : http://our.umbraco.org/documentation/reference/Events-v6/ContentService-Events
And the relatons API documentation : http://our.umbraco.org/documentation/reference/Management-v6/Services/RelationService
Dave
Hi Dave,
thank you for your reply.
Do you have an idea how to use the nuPicker for my solution, linking class to students pls? Because i have installed but there is quite some fields, such as Assembly for DotNet, etc, which I don't have an idea how to implement it.
Thank you in advance.
Regards
Simon
Hi Dave,
Or are there any simple solution because it seems quite complicated for such relationship?
Regards
Hi Simon,
The first thing you need to do is create a relation type. You can do this under the developer section. Maybe you can read some more about relations in this post :
http://umbraco.com/follow-us/blog-archive/2012/12/7/getting-to-know-umbraco-relations
After you create your relation type you go to the developer section and create a new datatype called student picker. As a editor you choose nuPickers : Lucene PrefetchList. As Examine Searcher you choose InternalSearcher. In the Raw Query field you enter this : nodeTypeAlias:AliasOfYourStudentDoctype.
The other settings you are clear I think. On the bottom you have the option to choose a relation mapping. If you choose a relation there nuPickers will create the relation for you.
Dave
Thank you Dave for your reply.
I will try to use that by using the Raw Query : nodeTypeAlias:AliasOfYourStudentDoctype
The Key Field and Label Field to which are they referring to, please?
thank you.
Regards
Simon
The key field you can pick ID and for label you can pick Nodename.
The key field is what is stored. And label is what is displayed in the picker.
Hi Dave,
I tried to do a relationship, based on the guidlines that you have provided me, but when I created a content for Class, nothing showed next to Students.
I am attaching some screenshots to understand me better.
Appreciate any help.
thank you very much.
Regards
May be stupid question. Did you add the datatype to your class document type ?
Also I see you have : at the start of your raw query on the datatype. This should be removed.
Dave
Also I see that you have student as a label field. Is student a property on your doctype ? If not just enter nodeName there. And also change ID to id to be sure.
Dave
Ok Dave it works :)
But, now, how can see that Mark, for example has been assigned to 2HND class?
thank you.
Regards
nuPickers also contains a property editor called Relation Labes I think. That is what you need.
Hi Dave,
Thank you for your help!
Last qestion:- If I want to display the school class properties/info in the Student template, using the relation, what should I need to do?
Thank you
Regards
Hi Simon,
I never used this, but you probably need the relation API.
Maybe this blog post can help you :
http://our.umbraco.org/forum/developers/razor/28103-Using-relations-with-razor
Hi,
Regarding the nuPickers Lucene, such as TypeaheadList, using the Raw Query, are there any guide of what type of quries that you can pass to this Raw Query for Lucene?
Since I want to not to get, for example all students, because if I have hundreds of students, and eventually choose only 1 or 2, are there any way how you can modify the query execute a database call based on the search for example?
Regards
thanks
is working on a reply...