add more data to relationship

Hi,

is it possible to add more data to a relationship, other than 2 GUID's and relationship type?  For example, let's say we have 2 users who both attended the same event and now they are connected through a relationship type "eventAttendance", but we also want to know what kind of an event they attended together (i.e. game, concert, movie).   In this relationship I am interested in 2 pieces of information - that 2 users attended "some" event together in general, and also what kind of an event, so I can't just create a separate relationship type for each event, as I am interested in the more general relationship as well.

I hope it's clear what I mean...

Thanks!

 

  • No.

    In Elgg metadata is attached to entities, not relationships. In this case, the metadata "kind" would be attached to the entity subtype "event".

  • Hi,

    thanks for the reply!  In this case, how would I create a relationship between the users? Would I add users' IDs as metadata to the Event Entity, along with "kind" metadata?  So the event object would hold the list of all the attendees and if I would want to check if 2 users are connected through the event, I would search that list for their id's?

    I am just starting with ELGG, so maybe the answers to these are obvious.

    THanks!!

  • No, never put user ids in metadata as the system will not be able to respond properly if those users are deleted. Use relationships for that.

    There is plenty of API documentation avaialble in the docs area, but personally I just read the source code in engine/lib. Most of it is clearly documented.

    In particular, see add_entity_relationship in engine/lib/relationships.php

  • @Ezhi - I agree with Kevin - make the event an ElggObject and the users who attend the event have a relationship with that object. There are then some simple methods to do things like get a list of all people who attended an event.

  • oh, got it! I see what you mean!  Somehow I didn't make the leap from a connection between 2 users, to a connection between a user and an event, and another user and the same event! This way, 2 users are connected through the event.

    Thanks! :)