Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon 692 posts 1068 karma points
    Dec 12, 2014 @ 10:45
    Simon
    0

    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

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 12, 2014 @ 10:52
    Dave Woestenborghs
    0

    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

  • Simon 692 posts 1068 karma points
    Dec 12, 2014 @ 10:57
    Simon
    0

    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

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 12, 2014 @ 11:01
    Dave Woestenborghs
    0

    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

  • Simon 692 posts 1068 karma points
    Dec 12, 2014 @ 11:24
    Simon
    0

    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

  • Simon 692 posts 1068 karma points
    Dec 12, 2014 @ 11:27
    Simon
    0

    Hi Dave,

    Or are there any simple solution because it seems quite complicated for such relationship?

    Regards

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 12, 2014 @ 12:29
    Dave Woestenborghs
    0

    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

  • Simon 692 posts 1068 karma points
    Dec 12, 2014 @ 12:41
    Simon
    0

    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

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 12, 2014 @ 12:43
    Dave Woestenborghs
    0

    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.

  • Simon 692 posts 1068 karma points
    Dec 12, 2014 @ 13:05
    Simon
    0

    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

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 12, 2014 @ 13:11
    Dave Woestenborghs
    0

    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

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 12, 2014 @ 13:12
    Dave Woestenborghs
    0

    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

  • Simon 692 posts 1068 karma points
    Dec 12, 2014 @ 13:18
    Simon
    0

    Ok Dave it works :)

    But, now, how can see that Mark, for example has been assigned to 2HND class?

    thank you.

    Regards

     

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 12, 2014 @ 13:22
    Dave Woestenborghs
    0

    nuPickers also contains a property editor called Relation Labes I think. That is what you need.

  • Simon 692 posts 1068 karma points
    Dec 12, 2014 @ 13:51
    Simon
    0

    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

     

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Dec 12, 2014 @ 14:07
    Dave Woestenborghs
    0

    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

  • Simon 692 posts 1068 karma points
    Dec 17, 2014 @ 22:00
    Simon
    0

    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 

Please Sign in or register to post replies

Write your reply to:

Draft