Copied to clipboard

Flag this post as spam?

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


  • Nicolai Winch Kristensen 50 posts 70 karma points
    Oct 01, 2012 @ 23:15
    Nicolai Winch Kristensen
    0

    creating dropdown datatype with values relative node..

    Hi

    Im going to create a new datatype using the usercontrol wrapper (I think) - I have seen on Umbraco.tv tutorial for this

    Before I start up I like to know if im on the right track

    my umbraco solution is a multi website solution. Backend contains websites for many schools.

    nodestructure simplified like:

    schoolA

    home

    course1

    course2

    School B 

    home

    course1

    course2

    etc etc

     

    in the "school" node, when created, an ID for the school is entered. When creating af new "course" user right now is entering an ID for the course.( this ID is the key for fetching data from a webservice).

    but .. what I want to achive is, that instead of entering course ID in a texfield, user should instead have a drop down where values are courses available for the specific school. The courses available is selected with the school ID as key.

    my problem is now, how can I in my usercontrol for the dropdown datatype get the ID for the school. I cannot just ask by  a static nodeID, cause its relative to where the course node is created (fx if I create a course node for school B I would wnat the ID entered for School B)

    Can  somehow in my code for my datatype usercontrol fetch the school ID (for the school in which context the datatype is being used)?

    Does it make sense at all what im asking? :-)

     

     

     

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Oct 02, 2012 @ 10:45
    Hendy Racher
    0

    Hi Nicolai,

    If I understand correctly, I think you'll want to walk up the tree from the current document (assuming document API rather than nodes incase the course or school is unpublished) to the school to get it's property. How about:

    int schoolId = uQuery.GetCurrentDocument()
                              .GetAncestorDocuments()
                              .Where(x => x.ContentType.Alias == "School")
                              .First()
                              .GetProperty("schoolId");

    HTH,

    Hendy

  • Nicolai Winch Kristensen 50 posts 70 karma points
    Oct 02, 2012 @ 11:34
    Nicolai Winch Kristensen
    0

    Hi Hendy 

    Thx for the reply, its appriciated.

    - yes thats what I want to do. I was just afraid this wasnt possible to do in a wrapped datatype.

    I will now try an implement an get back wiht info if I succeeded.

     

    Best Regards

    Nicolai

Please Sign in or register to post replies

Write your reply to:

Draft