As we all familiar with the basics of normal filter and contextual filter. In this tutorial i won’t touch basics of views but The Contextual filter.
If you’re not familiar with Views Contextual Filters, It’s also known as Views Arguments in Drupal 6 and then got renamed for Drupal 7 as well. Essentially, Contextual Filters intelligently filters content to reduce the result set in various ways and is pretty powerful.It makes your View scalable and one View can be used on many pages on your site rather than having to create many views, one for each page / block.
Lets’ Begin with Contextual Filter
Example of Books, my use case is something like this: I have a node type "Books" with some additional field (Title/ Authored by). The view example.com/basics/
Step 1: Under the "Advanced" area of the Views UI admin, expand that and you will see "Contextual Filters".
Step 2: We are going to add “Content Authored By” & click on Apply (all displays)
Step 3: Select Provide default value under Default actions “Type: Raw value from URL” WHEN THE FILTER VALUE IS NOT IN THE URL
below you will get the Path component. so, based on your requirement you can set the path component. for now i’m keeping default path to 1 and click on Apply (all displays)
Step 4: Click on Save button and save the view page configuration. now you can visit the page example.com/basics/
Now Keep changing the available uid to load the page based on their user id.
E.g: with uid 3
E.g: with uid 4