Understanding and Using Views Contexual Filters

Views Contextual Filters is a feature of the Views module which allows a Views to accept filtering from url, or other inputs.  This allows you to create lists that depend on conditional or user input.  There are many reasons why you may want to filter a list based on url input.  Take for example of a list of articles.  You may have many articles and wish to categorize them.  In the case of this website I'd like to be able to filter my article lists by the different Tags I give the articles.  I have several taxonomy terms, CiviCRM, Drupal, and Integration. For this article and I am going to how how to create a simple page view that will take a term name as an url argument passed to Views Contextual Filter. 

I will create a page view with the path article-listing-by-tag.  That link has no arguments after it, and the page view returns all articles.  article-listing-by-tag/civicrm lists all the articles tagged with CiviCRM, and article-listing-by-tag/drupal lists all the articles tagged with Drupal.

Goto http://[your_drupal_root]/admin/structure/views/add

  1. Enter a name, maybe "Article Listing by tag"
  2. Select Content from the "Show" Select Box
  3. Select Article from the "of Type" Select Box
  4. Change the Title to "Articles"
  5. Items to display: 0
  6. Uncheck the use pager checkbox
  7. Click the "Contine and edit" button
  8. Expand the "Advanced" fieldset in the far right column
  9. Click "Add" under "Contextual Filters"
  10. Scroll down to the field shown in the image below:


11: Use these settings:



12. Then click apply

13. Save the view


You should now have a page view that will accept a term name from the Tag vocabulary