Contextual Filters are similar to the basic Filters, but they are more dynamic. For example you could use them to show only articles that the current user has created. Relationships are mostly used to get extra information from an entity. In this tutorial we use author relationship to get the name of the author and use it in a Display summary to list all the users that has written articles and count their posts.
You can add a default FILTER CRITERIA to show articles from a specific user:
But to specify the user in the URL or use current user you must add a contextual filter.
- Click Add next to CONTEXTUAL FILTERS and add an Authored By filter.
- Leave the default settings and hit Apply:
Now you will see all articles unless you provide user id in the URL.
- Add Content: Authored by field to show the author. Select Author as the Formatter:
- Go the view page (/home) and specify some user id in the url:
Now you see articles for a user specified in the url:
Use the Provide default value to use the current user as a filter:
Now the homepage shows only articles written by the current user:
You can use a Contextual Filter to create a Display summary.
Add a relationship to get the author name.
- Click Add next to RELATIONSHIPS and add a Content author relationship.
- Add a contextual filter User: Name.
- Select Display a summary and Number of records:
View so far:
Posted by Samuli Natri on 11 December 2015