Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drupal EntityReference / References / Relation talk

Drupal EntityReference / References / Relation talk

Delivered on April 27th, 2013 at the Western New York Drupal Mini-Camp

Adam White

April 27, 2013
Tweet

More Decks by Adam White

Other Decks in Programming

Transcript

  1. WHICH MODULE SHOULD YOU USE? Well there’s ENTITY REFERENCE, which

    is very popular, and then there’s REFERENCES, which isn’t the same thing but similar, then there’s RELATION which is the most popular! Doesn’t ORGANIC GROUPS do this?
  2. BREAK IT DOWN ENTITY REFERENCE - Probably RELATION - Specific

    Use Case REFERENCES - Legacy ORGANIC GROUPS - If you’re already...
  3. WHY ELSE? Lots of support from big commercial Drupal shops,

    IE: Drupal Commerce has added a lot of cool stuff (inline editor!). Out of the box comes with some nice widgets (select / radios & checkboxes / autocomplete)
  4. WHY NOT? EntityReference is designed for 1-n relationships (one entity

    relates to many others). The relation lives on an entity, as a field, not truly in between entities. Not fieldable :(
  5. IT’S A FIELD! While it’s possible to copy a reference

    field from one entity to another (Corresponding Entity Reference /cer) this is a duplication of data. Editing a reference edits the modified date on the entity, etc.
  6. FIELDABLE? Relations can therefore easily handle shared fields of data

    that’s owned by the relation entity itself.
  7. IE JOHN has an ACCOUNT at BANK OF AMERICA with

    a balance of $100. ADAM is FRIENDS with JULIE and they met in high school.
  8. WHY NOT JUST USE ECK? You could build something very

    similar to Reference using the Entity Construction Kit by creating an entity that has EntityReference fields... but...
  9. IT WOULDN’T BE ABLE TO... • have different kinds of

    entities connected to a single endpoint • handle symmetrical relations (IE, one rule is fired for both ends of the relationship) • list siblings in views • support revisions
  10. SYMMETRICAL RELATIONS VINCE, PETER, and BETTY are SIBLINGS. in which

    the relation points in all directions, there’s no owner of the SIBLING relationship.
  11. SO WHAT’S THE CATCH? The Relations UI is often ugly

    and weird for anyone but space robots and mad scientists. That’s a fixable problem, with time.
  12. WIERD UI Ships with the “Relation Add Module” which is

    like a shopping cart for relating entities shown on a given page IE: not the use case of anyone in the real world ever.
  13. REFERENCES http://drupal.org/project/references Exists as a direct upgrade path for those

    users who were using the CCK node_reference and user_reference fields in D6 and wanted an equivalent in D7. Popular, but doomed.
  14. UPGRADE PATH Given where EntityReference is headed in Drupal 8,

    even the References folks are suggesting you migrate that way. A module (drush plugin) exists to do just that.
  15. ORGANIC GROUPS Through OG’s concept of grouping content together for

    users who are members of these groups, it can be used as a mechanism to relate entities together... However...
  16. ORGANIC GROUPS OG is massive and has a lot more

    going on than just linking things. Unless your project is already built around OG you probably don’t want to introduce it for the sake of relating things...
  17. CORE Since EntityReference is in core it’s the most future

    proof. That said, Relation’s got their D8 branch up...
  18. PREDICTION / RECOMMENDATION Look for the things that Relation does

    better to be either be incorporated into EntityReference, or for Relation to start using parts of core EntityReference under the hood... So use ER until you can’t...