Slide 1

Slide 1 text

The Relation module: Because having one way of doing things just wouldn’t be Drupal.

Slide 2

Slide 2 text

SO YOU WANT TO RELATE SOME STUFF TO SOME OTHER STUFF? Easy!

Slide 3

Slide 3 text

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?

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

BREAK IT DOWN ENTITY REFERENCE - Probably RELATION - Specific Use Case REFERENCES - Legacy ORGANIC GROUPS - If you’re already...

Slide 6

Slide 6 text

ENTITYREFERENCE

Slide 7

Slide 7 text

ENTITYREFERENCE http://drupal.org/project/entityreference Lots of use and support (68,748 installs) Integration with all the toys (Views, Devel generate, Feeds and Migrate)

Slide 8

Slide 8 text

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)

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

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 :(

Slide 11

Slide 11 text

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.

Slide 12

Slide 12 text

RELATION

Slide 13

Slide 13 text

RELATION http://drupal.org/project/relation Relations are entities, not fields! Since they’re entities, relations are fieldable. This is awesome.

Slide 14

Slide 14 text

FIELDABLE? Relations can therefore easily handle shared fields of data that’s owned by the relation entity itself.

Slide 15

Slide 15 text

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.

Slide 16

Slide 16 text

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...

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

MULTIPLE TYPE PER ENDPOINT USER ADAM, NODE 123, and TAXONOMY TERM 5 are ALL THE THINGS.

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

SYMMETRICAL RELATIONS VINCE, PETER, and BETTY are SIBLINGS. in which the relation points in all directions, there’s no owner of the SIBLING relationship.

Slide 21

Slide 21 text

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.

Slide 22

Slide 22 text

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.

Slide 23

Slide 23 text

REFERENCES

Slide 24

Slide 24 text

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.

Slide 25

Slide 25 text

REFERENCES

Slide 26

Slide 26 text

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.

Slide 27

Slide 27 text

ORGANIC GROUPS http://drupal.org/project/og Is in this deck because Nick asked me to talk about it...

Slide 28

Slide 28 text

ORGANIC GROUPS

Slide 29

Slide 29 text

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...

Slide 30

Slide 30 text

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...

Slide 31

Slide 31 text

...IN THE FUTURE EntityReference is in flippin’ CORE in Drupal 8:

Slide 32

Slide 32 text

CORE Since EntityReference is in core it’s the most future proof. That said, Relation’s got their D8 branch up...

Slide 33

Slide 33 text

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...

Slide 34

Slide 34 text

Adam White If you want these slides: www.upperrapids.ca/relation @adamwhite @upperrapids