Single Exposed Filter Block for Multiple Views Displays



January 12, 2015

Chances are, any two visitors to your website will have different preferences when it comes to consuming the content you're offering. People browse websites for various purposes, with a wide variety of preferences and biaises. Providing visitors with options on how content is displayed is appreciated when presented via an intuitive user interface.

In the past, clients have asked me to display lists of content in multiple formats (which is fairly straightforward with a basic understanding of the Views module) and to allow the user to decide what format is most approriate. In this example, I'll use geographical data as well as a summary of the location of each of the Canadian National Museums located in my hometown of Ottawa, ON.

Using Views and the Chaos Tools sub-module "Views Content Panes", I configure two views displays. The first pane contains an OpenLayers map (I should write another blog post as a brief tutorial to OpenLayers, too, but we'll save that for another day) and the second pane contains a list of content "teasers". For both of my displays, I add an exposed filter for the Title field (the name of the Museum) and on both displays, I check the box to have the exposed form in a separate block. I also ensure that the pane will use the panel path.

Content Pane Details Screenshot

There are infinite ways to get both of these panes on the same page, but what I do in this example is throw them into a QuickTabs instance. Then I add the exposed filter block (for either of the two panes) into the sidebar. The result looks something like this:

Screenshot of a Map of Ottawa with Museums locations

When I filter the results to only include Museums with the word "Laurier" in the title, ?title=Laurier is added to the url as a query string and both views accept this argument, limiting the results of both the "Map" display and the "Details" display to Laurier House.

Screenshot of the Laurier House description page

Et Voilà! Visitors to my site can filter through the information I'm offering in a simple, intuitive way and choose whether they want to view a photo and the summary of the location or the geographic location of the museum on a map.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.