In order to display values for referenced entities in views, you need to add a relationship. What is a relationship, how do they work, and what does it mean to require this relationship? What are some common use cases for adding a relationship to a view? By the end of this tutorial you should be able to:
Nearly every major component that makes up a Drupal site is an entity of one type or another, e.g. users, nodes, and blocks are all types of entities. All entities can then be customized by adding fields to them. Understanding how Drupal's Entity system works is fundamental to understanding the similarities and differences between the main components that make up a Drupal site. You can alter existing entity types to make them work more efficiently for your site, and it's also possible to create your own entity types to encapsulate the behavior of specific data structures within your application.
In Drupal, entity is a general concept that represents a noun (person, place or thing). Out of the box, there are a number of different types of entities in Drupal, each meant to represent a specific type of data.
One type of entity is a user. A user entity contains information that is specific to people that visit our site, such as the user's email address and password. Within the concept that entities represent nouns, a user entity is a person.
Another entity type in Drupal is content (sometimes called a node) entity. Content entities contain data that is relevant for a something that is expected to be visited and consumed, such as a URL path, title, and body. Continuing with the concept that entities represent nouns, a content entity is a place. It has a URL and can be visited and it contains content that is meant to be consumed by a visitor.
Additionally, each content entity in Drupal has an owner. The owner (often referred to as the author) of a specific piece of content is a user entity. Most often the owner of some content is the user that created the content. Continuing with our analogy of a user representing a person and content representing a place, then it makes sense that a person would own a place. This concept of a user entity owning a content entity is a relationship. And that relationship is made practical in our site by the use of entity reference fields.
- Understand what components of a Drupal site are entities
- Understand the difference between configuration and content entities
- Know when, and how to create custom entities
At this point the Entities are relatively stable. Any major changes to the API at this point are likely to be new features, or slight changes in best practices as they emerge. The fundamentals and main components of the system are unlikely to change rapidly.
Entities and fields are closely related and the boundaries between the two are often confused. It's generally a good idea to learn both in order to properly use either one.