Copied to clipboard

Flag this post as spam?

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


  • webmonger 130 posts 285 karma points
    Aug 27, 2009 @ 17:52
    webmonger
    0

    Link Node id to member Id

    Hey

    I'm building a system that requires a member to be linked to another content node and for one additional attribute to be added with the link information.

    Basically I have a Member that say "I'm going to this event", "I'm thinking about going", "I'm not going" so these are the additional attributes I'll probably hold as settings Nodes.

    And now at the front end when the user is on the website (and signed in) i want them to be able to click a button that will link their Member ID to the Node ID with the additional attribute as described above.

    Please could someone give me an idea of whether this can be done with the Umbraco ID in stead of creating additional tables in the database?

    Cheers

    Jon

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 27, 2009 @ 18:53
    Dirk De Grave
    0

    Hi Jon,

    You could establish a relationship between a member (or its id) and a content node id) using the existing umbraco api (it's similar as when you're copying nodes - there's a little checkbox 'related item'). I know of some blog posts about this subject, just can't find those atm, will do some searching...

     

    Cheers,

    /Dirk

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 27, 2009 @ 19:01
    Dirk De Grave
    0

    Found it... http://blog.hendyracher.co.uk/umbraco-relation-api/

    Alternative solution: add an extra property on the member type to hold the node id.

     

    Cheers,

    /Dirk

  • webmonger 130 posts 285 karma points
    Aug 28, 2009 @ 10:46
    webmonger
    0

    Hi Dirk

    That looks like what I'm needing the only addition to that is the third link or attribute. That is the flag to say "I'm going to this event", "I'm thinking about going", "I'm not going"

    As any Member can link to 1 or many Events I don't want to hold this additional attribute on the Event or on the Member but on the link.

    I cant see a good way of chaining the relationship so I link Member to attribute to Event, I think it really needs to work Member to (Link with additional attribute) to Event.

    any ideas?

    Cheers

    Jon

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Sep 01, 2009 @ 12:29
    Hendy Racher
    0

    Hi Jon,

    How about adding three rows to the umbracoRelationType table to define each of these relationships ?

    You can then infer the type of association between MemberID to NodeID by the particular relationship alias used.

    HTH,

    Hendy

  • webmonger 130 posts 285 karma points
    Sep 02, 2009 @ 17:04
    webmonger
    0

    Hi Hendy

    Cheers for the help. I'm still a little confused but i'll try to explain and see if i'm going down the right route. At the moment i think of the relationships as:

    1. Link Event to Attendance - This is a ContentItem to ContentItem Relationship. I'll call it relateEventToAttendance

    2. Link Attendance to Member - This is a ContentItem to Member Relationship. I'll call it relateAttendanceToMember

    I think i'm missing a step at the moment. I need to unbind the relationship between the Node and the AttendanceType and the Member and AttendanceType but i dont know how to do that. Any pointers you have to add the third relationship to disconnect these 2 things would be very much appreciated.

    Cheers

    Jon

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Sep 02, 2009 @ 21:31
    Hendy Racher
    0

    Hi Jon,

    My initial thoughts were three db rows, creating relationships that define how a member can be associated to an event.

    id dual parentObjectType childObjectType name alias
    .. 1 39EB0F98-B348-42A1-8662-E7EB18487560 C66BA18E-EAF3-4CFF-8A22-41B16D66A972 Member is going to this Event relateMemberGoingEvent
    .. 1 39EB0F98-B348-42A1-8662-E7EB18487560 C66BA18E-EAF3-4CFF-8A22-41B16D66A972 Member is considering going to this Event relateMemberConsideringEvent
    .. 1 39EB0F98-B348-42A1-8662-E7EB18487560 C66BA18E-EAF3-4CFF-8A22-41B16D66A972 Member is not going this Event relateMemberNotGoingEvent

     

    You could then use the API like :

    /* Get all Members going to Event */
    
    RelationType relationType = RelationType.GetByAlias("relateMemberGoingEvent");
    Relation[] relations = Relation.GetRelations(documentEvent.Id, relationType);
    
    Member member;
    foreach (Relation relation in relations)
    { 
      member = new Member(relation.Parent.Id); 
    }
    

    (I've not tested it, but as 'dual = 1' on the relation type, I think it looks on both keys.)

  • webmonger 130 posts 285 karma points
    Sep 03, 2009 @ 11:57
    webmonger
    0

    Ahh. Yes absolutley I was coming at the issue from the point of view of how i would do it in a DB. The way you sugest for three options works perfectly however it would get somewhat problematic if it became a true many to many relationship.

    Cheers

    Jon

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Sep 03, 2009 @ 12:01
    Hendy Racher
    0

    Hi Jon, how do you mean it'll become problematic ?

  • webmonger 130 posts 285 karma points
    Sep 03, 2009 @ 12:20
    webmonger
    0

    The problematic bit does not relate to my problem.

    But i mean if you have for example 100 or 1000 possible links that are required then you'll need to add a Relationship Type for each possible link and if you have 3 places where this is required then you have the potential to have 3x 100 or 3x 1000 Relationship Types.

    I don't see it being very managable at that stage.

    Maybe i'm barking up the wrong tree though and there is a better way.

    Jon

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Sep 03, 2009 @ 12:37
    Hendy Racher
    0

    Slightly abstract, but It's a shame there isn't an ObjectType guid for a RelationType; was thinking how to implement a hierarachy of RelationTypes, and what benefits that could offer...

  • webmonger 130 posts 285 karma points
    Sep 03, 2009 @ 12:44
    webmonger
    0

    Yes thats what i was thinking because then you would only ever need 3 types to do any type of linking. I guess it may be worth a feature request.

Please Sign in or register to post replies

Write your reply to:

Draft