In this video, I'll show you how to enhance a view with a Relationship that will allow us to access additional information that isn't available by default.


Relationships are a way of "linking" related information. A normal view selects information from one data source, such as a node that meets the filter criteria. In our case, we're displaying information from the node table in the database about products. But our view doesn't have access to information from other sources, like the user table in the database. If we click add in the fields section, we'll find that the only user information we have access to in relation to our nodes is the Author uid. If we want to include other information from the user table, like the user name, then we need to add a Relationship to allow us to relate one data source (the node table) to another (the user table).

So our next step will be to add another field for author name, and to do that we have to pull in information from the user table through a relationship.

To add relationship:

  • Click "Add"
  • [x] Content: Author
  • (Apply(all displays))
  • (Apply(all displays))

Now, we can add another field for content author.

  • Click "Add" next to fields
  • Filter: Choose "User" (Notice that we now have "User" and we can use that to pull in information from the user table)
  • [x] User: Name
  • (Apply(all displays)) (On the next page, you'll notice the "Relationship" field is filled with "author")
  • Label: Posted by
  • [x] Link this field to its user: (This will render the user name as link to the profile of user.)
  • (Apply(all displays))
  • (Save) (Save the view)

Now, when we scroll down to the live preview, we'll see that we have a field for the author name.