What is the difference between normal filter and contextual filter in views?

Solutions

I'm just quoting d.o. and accentuate:

Contextual filters work similarly to regular filters, but there is one important difference. Instead of setting a filter value manually, the value is fetched from variables sent programmatically to the view. A regular filter could give you all nodes written by a specified user. A contextual filter for a node author would be able to display all nodes written by the currently viewed user, or the same user who wrote the currently viewed node. The concept is that contextual filters prepare a view for filtering, but the filter value is not yet determined. When the view is eventually called, it is also provided with data used to complete the contextual filters.

Recommended further reading: Contextual Filters on d.o.

In simplified language to understand.

Normal Filter: Normal filter takes the fixed data from the available data. For example, you have created a views with Content: Title which will show all the title of nodes available on the site. But if you provide the Filter: Content type(Articles), then it will show only the Node title of Articles. Hence here filter, filters all data and gives only data which belong to Articles. So this is the Normal filter.

Contextual Filter: Now, Sometimes, you do not have the fixed filter value, suppose, Logged-in-user, value available in URL, Author name of currently loaded page. So, this kind of filter values are dynamic and keep changing, so Contextual filter provides the way to solve this. To visualize this you can see the following UI image of contextual filter. Which has mainly two section.

1. WHEN THE FILTER VALUE IS NOT AVAILABLE

2. WHEN THE FILTER VALUE IS AVAILABLE OR DEFAULT IS PROVIDED.

Now, in the first option WHEN THE FILTER VALUE IS NOT AVAILABLE itself defines what is Contextual filter is- So, Contextual filter SAYS to you, "I can fetch value from following listed areas(as you can see in image), you select from where shall I fetch. And I will take it as Filter value."

Example to understand Contextual filter: Now your site has the Taxonomy terms- BMW, AUDI, HONDA. So, in fixed value filter you can take only one value. But, what you will do when that value is keep on changing based on browsing.

So, suppose, I select contextual filter and select Taxonomy term ID from URL So, if URL will have BMW is will take BMW as filter, If URL will have AUDI it will take AUDI as filter value. So, filter value keep on changing here, hence Contextual filter provides the way for this.

enter image description here

In short, both filter the data shown from the view, but a contextual filter filters the data basing on the values passed in the view's URL.
It is also true that it is possible to tell the view what to do when a value is not present in the URL (so that the view can handle two different URLs like blogs and blogs/%user), but this is essentially the difference between the two kind of view filters.

Also, normal filters can be exposed to the user, so that they can change the data shown in a view by changing the value of the filter. This cannot be done for contextual filters.

Tags: Drupal 7 / Views

Similar questions

What is the difference between rendered entity and content in views 3?
In the Format option for a view, the options include Content and Rendered Entity. They both offer you a selection of view mode for the content. The former includes some extra options on comments/links. So what is the point of Rendered Entity if it's a single configuration of Content? Suspect I'm missing something!
In Views, what is the difference between "Show Fields" and "Show Content" under Format?
In the Format section you have the option Show: Fields. That is the one I usually use. However, you also have Show:content. What is Show:content and how is it different? When would I want to use it instead of Show:fields?
Difference between Content: Updated date and Content revision: Updated date in Views
In views Filter criteria, What is the difference between Content: Updated date and Content revision: Updated date?
What is the difference between Referenced Entity and Referencing entity in views
I just wanted to know what is major difference between Entity Reference: Referenced Entity A bridge to the Content entity that is referenced via field_FIELD_NAME AND Entity Reference: Referencing entity A bridge to the Content entity that is referencing Content via field_FIELD_NAME While using relationship in views or when I prefer to Entity Refere...
What's the difference between 'attachment before' and 'block' in views?
Recently I followed a tutorial in views which listed taxonomy and gave me a short list above the view with hyperlinked first characters of taxonomy name. In this case, I created a "block". In investigating the default Glossary view, I see the same hyperlinked first characters of title created by using "Attachment before". Are there advantages of us...
How do I calculate the days difference between start and end date of a date range field in Views PHP?
I'm trying to get the total number of days in a date range field using Views PHP. Any help will be greatly appreciated. I tried the code below first in "value code" then in "output code" but it didn't do anything.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.