Book Image

Mastering Drupal 8 Views

By : Gregg Marshall
Book Image

Mastering Drupal 8 Views

By: Gregg Marshall

Overview of this book

Learn how to build complex displays of content—all without programming. Views were used on more than 80% of all Drupal 7 sites; now they are part of the Drupal 8 core. While most site builders and site owners are aware of views, they don't understand how to take full advantage of their power to create many amazing pages and blocks. If they use views, they might build 10 different view displays with different filters, without knowing that a contextual filter would require only a single display. Using our sample company, we'll take its existing content and evolve an ever more complex and powerful website for that company, starting with adapting the administration the user sees and moving on to making complex pages of information for site visitors. While the book is written for Drupal 8, the similarities between Views in Drupal 7 and 8 make this a useful reference for Drupal 7 site builders also.
Table of Contents (20 chapters)
Mastering Drupal 8 Views
Credits
Foreword
About the Author
Acknowledgements
About the Reviewer
www.PacktPub.com
Preface
Index

Chapter 4. Contextual Filters

In the last chapter, sorting and filtering was explained. Sorting lets site builders specify what order their data lists should be in. Filtering lets site builders select just a portion of a large list, such as the Tiny House page that selects properties of less than 500 square feet from the total list of available properties. Exposed filters allow visitors to select the values or ranges of values that are most interesting to them, making the lists of data more interactive and useful.

Filters require the site builder to select the values or expose the filter to allow the visitor to select the values. As a result, it is common to see a single view with a dozen displays, each with a filter or two set to specific values, such as a neighborhood. There is a better way that allows Drupal to take a value from the URL or use information gathered from what page is displayed to filter results. This capability is called contextual filtering. Even though contextual filters...