Adding a relationship in a View
As stated at the beginning of the chapter, Views is a visual query builder. When you first create a view, a base table is specified from which to pull data. Views automatically knows how to join tables for field data, such as body text or custom-attached fields.
When using an entity reference field, you can display the value as the raw identifier, the referenced entity's label, or the entire rendered entity. However, if you add a relationship based on a reference field, you will have access to display any of that entity's available fields.
In this recipe, we will update the Files view, used for administering files, to display the username of the user who uploaded the file.
How to do it...
- Got to
Structure
and thenViews
. This will bring you to the administrative overview of all the views that have been created - Find the
Files
view and click onEdit
.
- Click on
Advanced
to expand the section and then click onAdd
that is next toRelationships
. - Search for
user
. Select...