Relationships are a very important part of Drupal, so taxonomy terms and content, users and content, goods and the display of goods in commerce are combined. Thanks to this, we can display user fields when displaying material fields, and when displaying goods, we can display their price and article number.
Thanks to this, we can display user fields when displaying material fields, and when displaying goods, we can display their price and article number.
Let's create a view that will display information about the user who created the material on the page of which we are located in the block. In one of the previous lessons we have already figured out how to use the context filter and display the information about the page we are on:
Name of the view: Author's information
Machine name: athor_info
View Settings: Contents, Announcements
Create a block, with one entry.
Now you need to add a context filter by Content: ID:
Now you need to add a context filter by Content: Content ID:
As in the last article, let's set the Provide default value: Content ID from URL.
We now have the node fields available on the page where we are located. But we need the author's fields. At the moment we can only access the author's UID field:
It's time to add the author's relationships:
After that we will be able to add the node author's fields: avatar, name, date of the last visit to the site and other fields. When you add its fields, the view automatically exposes the field of relationships:
I've added several fields at once:
Contents: Authored by
(author) User: Picture
(author) User: UUID
(author) User: User status
(author) User: Name
(author) User: Updated date
Let's now display this block on the announcements page. You can set a block in the visibility area so that it is displayed only on the content tupe in the announcements.
That's it, we've figured out how to use the relationships in the view, and later on we'll use them more than once, so if not everything is clear now, just move on to the next article.